Skip to content

Documentation

Maurits Kok edited this page Jul 15, 2022 · 5 revisions

Sphinx

We use Sphinx to generate the documentation for the project. For a general introduction into sphinx, please check out the following resources:

Updating the documentation

All documentation that sphinx needs to parse, should stored in the /docs folder. The documentation itself can be of .rst or .md format. All files to be included in the documentation need to be listed in the file index.rst. This file also generates the table of contents. Simple add a new .rst or .md file in the sphinx folder (or any subfolder) and add a link to it in index.rst.

The API references are generated with sphinx-apidoc. This project follows the Numpy style for writing docstrings.

The API references are build from the file docs/api.rst. This file contains the instructions for sphinx to retrieve all the docstrings from the functions within each of the modules in the project. The generic instruction set is (in .rst format)

ddm.<name_of_module>
--------------------

.. automodule:: ddm.<name_of_module>
   :members:
   :undoc-members:
   :show-inheritance:

Sphinx configuration

Sphinx is configuration can be found in the file docs/conf.py. Here, you can add additional features through extensions or change the theme. Note, you might need to install the extensions or themes with pip. If so, please add them as dependencies in setup.cfg under the development dependencies.

Building the documentation locally

If you want to view the documentation locally on your own system, please install the ddm package with the development dependencies with

pip install -e .[dev]

It is also recommended (but not required) to install Make.

You can build the documentation locally using Make with

cd docs/
make html

or without Make with

sphinx-build ./docs _build

You can then view the documentation by opening the file docs/_build/html/index.rst in a webbrowser.

Automatically publish a documentation website

We have set up a GitHub action to build and publish the documentation when we push a new commit to the master branch. The workflow can be found in .github/workflows/CI_pages.yml and the webpage at https://koenderinklab.github.io/ddmPilotCode/.

Publishing documentation as a website is handled by GitHub with GitHub pages. In the settings of the repository, under the tab pages, we have pointed GitHub to the branch gh-pages to find the (sphinx-build) documentation. When the CI_pages action is run, it will build the documentation with sphinx and push the changes to the branch gh-pages. GitHub will then update the webpages accordingly.