A small python library to generate rich documentation from SAS code
This library relies on the parsy parsing library to parse SAS code and generate python objects representing SAS concepts.
The library also allows for these objects to be converted into readable documentation using sphinx.
$ pip install git+https://github.com/benjamincorcoran/sasdocs
or clone this repository and pip install locally.
$ git clone https://github.com/benjamincorcoran/sasdocs
$ pip install ./sasdocs
Complete documentation available at ReadTheDocs.io
This module can be used as part of a python project to explore static SAS code, or in tandem with sphinx to autogenerate documentation from SAS code.
In the tests/samples folder in this repository there are three .sas files.
├───samples
│ macro_1.sas
│ macro_2.sas
│ simple_1.sas
Using the below code, we can generate a SASProject object that will collect all of these files and parse them.
from sasdocs.project import sasProject
prj = sasProject("./tests/samples")
This prj
instance now contains several attributes that can be used to describe the project and in the individual programs contained within.
print(prj.name)
>> "samples"
print(prj.programs)
>> [macro_1.sas, macro_2.sas, simple_1.sas]
print(prj.summary)
>> {'dataStep': 7, 'macro': 4, 'include': 2, 'procedure': 3}
Any .rst file in your source directory can call the sasinclude directive which will parse the passed SAS file or all SAS files found in the folder and return the result at the point that the directive is called.
.. This will parse sasprogram1.sas and return the result.
.. sasinclude:: ..\sasprograms\sasprogram1.sas
.. This will parse all programs in the ..\sasprograms directory and return the results here.
.. sasinclude:: ..\sasprograms\
Ben Corcoran - 2019