This repository gives a minimal example of the building and publishing documentation for a Python module using Sphinx, GitHub actions and github-pages.
Key points are:
- automatic and recursive building of the documentation from documented Python modules using sphinx autosummary
- working sphinx-gallery -- see for exemple matplotlib's gallery.
- automatic building and publishing using GitHub actions when committing changes to repo.
- clone the repository
- install requirements
pip install -r requirements.txt
- build the documentation locally
cd
docs && make htmland check the files in
_build/html(open
index.html` in a browser) - push the repo on a github repo. Check that the github actions worked fine.
- enable github pages, with source
gh-pages/(root)
- you should be able to see the documentation at
https://user.github.io/repo/
- be sure to have some docstrings written inside your python module (see here.)
- create a
docs
folder, and run insidesphinx-quickstart
- tune your
conf.py
as you may wish. Note that it must include everything linked tosphinx-gallery
if you wish to include one - run
make.html
and pray.
Important things:
- Look at
api.rst
andindex.rst
file structures, it is important. - If you wish to document imports inside
__init__.py
files, setautosummary_imported_members = True
in yourconf.py
.
-
Sphinx documentation:
-
building and publishing using github actions: