Skip to content

benjamincorcoran/sasdocs

Repository files navigation

SASDocumentationLogo

sasdocs

A small python library to generate rich documentation from SAS code

Build Status Documentation Status Commits Coveralls github branch

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.

Installation

$ 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

Documentation

Complete documentation available at ReadTheDocs.io

Usage

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.

Simple Example

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}

Sphinx directives

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\

Contributors

Ben Corcoran - 2019

Ask Me Anything ! Follow

License

License: MIT

About

A small parsing library for SAS code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published