Skip to content

Instantly share code, notes, and snippets.

@PaulCreusy
Last active July 3, 2024 12:18
Show Gist options
  • Save PaulCreusy/8d16d7d60e7e55b6ce629c9172910678 to your computer and use it in GitHub Desktop.
Save PaulCreusy/8d16d7d60e7e55b6ce629c9172910678 to your computer and use it in GitHub Desktop.

Instructions to create automatic sphinx documentation based on app modules and packages

Install required packages

Install the following packages.

sphinx==7.2.6
sphinx_rtd_theme==2.0.0

Create the sphinx documentation

Run the following command in the terminal to create a documentation on all modules and packages contained in your project.

sphinx-apidoc -d 5 -e -M -a -F -f -H <Project name> -A <Author name> -V <Version number> -o docs . <Exclusion patterns (optional)>

⚠️ Warning
Before running this command, make sure that each of your packages has a __init__.py file.

Here is an example:

sphinx-apidoc -d 5 -e -M -a -F -f -H Bond -A Paul_Creusy -V 1.0.0 -o docs . draft*

Set the theme

Go to the file docs/conf.py and:

  • add sphinx_rtd_theme to the extensions_list variable
  • change html_theme to sphinx_rtd_theme

Change the docstring format

If you are using Numpy or Google docstring style, you will need to add the extension sphinx.ext.napoleon to the list in the docs/conf.py file.

Export the documentation

Run the following commands:

cd docs
make html

Open the documentation

Open the file docs/_build/index.html in your web browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment