Sphinx + Python on Github Pages / Jekyll

Sphinx works great with Github Pages. Sphinx requires one-time setup as described below. The URL will be like https://geospace-code.github.io/pymap3d/.

Install Sphinx

Setup an environment for Sphinx otherwise it may downgrade other packages:

conda create -n sphinx

conda activate sphinx

Install Sphinx

pip install sphinx

setup docs

Use Sphinx Quickstart


Most defaults are fine, except:

autodoc: automatically insert docstrings from modules (y/n) [n]: y
mathjax: include math, rendered in the browser by MathJax (y/n) [n]: y
viewcode: include links to the source code of documented Python objects (y/n) [n]: y
githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]: y

Add to .gitignore


Edit docs/Makefile to include

BUILDDIR      = .

Create empty docs/.nojekyll or else Jekyll will reject all directories starting with _, breaking the Sphinx docs.

Edit docs/index.rst to have entries like

.. automodule:: pymap3d

.. automodule:: pymap3d.vincenty

Create docs/index.html containing only

<meta http-equiv="refresh" content="0; url=html/index.html" />

Add the docs directory to Git

git add docs/

In your Github repo Settings → Github Pages → Source: “master branch /docs folder”

git commit and git push. It takes a few seconds for Github Pages to deploy your HTML.

Easier to use pdoc Python autodoc generator