- Want to write documents and docstrings for a Python module and turn them into a presentable form.
- Build and host your doc on readthedocs.io (if you don't mind open source your code on github.com) ...
Or build and host your doc on your own.
This is a recommended way to organize your code (e.g. if you have a module named my_mod
)
my_mod-pkg/ (base dir for Git, etc.)
|--- README.md
|--- my_mod/
|--- __init__.py
|--- whatever.py
|--- docs/
Now we assume that you are at base dir my_mod-pkg/
and you don't have my_mod-pkg/docs
created yet.
pip install sphinx sphinx_rtd_theme # or conda install ...
bash init-doc.sh
Run this only once, and enter your project information as prompted.
Now you can start writing document pages in my_mod-pkg/docs/source
using reStructuredText format. Don't worry if you have never work with it before. You can learn how people are doing it by browsing the docs/
dir in existing Python projects.
When your are ready, on my_mod-pkg/docs/
do:
pip install -r requirements.txt
make html
If it builds successfully, you can pull up a simple Python HTTP server to view the generated document locally:
python -m http.server 8080
# Open your browser, go to localhost:8080
You need an account for that and link your GitHub repo.
Additionally, it takes a config file my_mod-pkg/.readthedocs.yml
, e.g.:
version: 2
python:
version: 3.8
install:
- requirements: docs/requirements.txt