A documentation generator that reads docstrings and variables defined in the controllers, permissions, serializers, urls, and views of a CloudCIX Application, and uses the details to generate OpenAPI compliant JSON to be used by https://docs.cloudcix.com.
The current version of the docgen Wiki is in line with the work done in the Membership Python 3 Application, so look to that if there's any confusion.
- Install the module using
pip;pip install git+https://github.com/CloudCIX/docgen.git
- Add
docgentoINSTALLED_APPSin the Django settings file - Set up Docstrings as per docgen Wiki
- Add a
DOCS_PATHsetting to the Django settings file, giving a path to store the generated JSON file - Run
python manage.py docgen <application>to generate documentation for<application>
Example settings.py
INSTALLED_APPS = [
...
'docgen',
...
]
...
DOCS_PATH = '/application_framework/system_conf/docs.json'--output- Specify a new output path rather than using
settings.DOCS_PATH
- Specify a new output path rather than using
--debug- Turn on some level of debug logging to try and help find out why things aren't working
The docgen Wiki details how docstrings and other things should be laid out in a project for correct documentation to be generated.
Most documentation is done through Python docstrings
You should also familiarise yourself with the OpenAPI Documentation layout first before diving in to do documentation.
Also, since some docstrings are parsed with YAML, it is recommended to look at the YAML specification for details.
In order to get as much information into the docstrings as possible, without making them look ugly, we're going to use a YAML subset for most docstrings.
The docgen tool uses yaml.load on the following docstrings;
- Controller Validation Methods
- Serializers
- View Methods (
get,post,putanddelete)
The docgen tool also pulls docstrings from the following locations, albeit not parsing them as YAML;
The structure of the docstrings are outlined in their respective wiki entries.
For list methods, the documentation for fields usable for filtering and ordering are generated from the ListController.Meta.search_fields and ListController.Meta.allowed_ordering respectively.
For ordering, it also assumes that the first field in the tuple is the default (as it should be) and marks it as such.
This tool is set up to be super strict when it comes to parsing the information from the code. Each of the above wiki pages will have a section detailing what things will cause errors when the respective section is being parsed.
The tool goes through the entire codebase before printing out all the errors, so all errors in one run of the tool will be presented to the user at once.