Show Menu
Cheatography

Sphinx - automatic documentation Cheat Sheet by

Step by step instruction to automatically generate docs with Sphinx for Python project

INSTAL­LATION

conda install sphinx
Install sphinx package
conda install sphinx­_rt­d_theme
Install theme for docs

INITIAL SETUP

mkdir docs
Create docs folder in project directory
cd docs
Move to docs directory
sphinx­-qu­ick­start
Fill in details about your project

MODIFY CONFIG­URATION FILE (docs/­sou­rce­/co­nf.py)

## Uncomment and add path to project files (lines 13-15)
import os
import sys
sys.path.insert(0, os.path.abspath('../project_dir'))

## Update extensions (line 30)
extensions = ['sphinx.ext.autodoc','sphinx.ext.napoleon']

## Update the theme (line 50)
html_theme = 'sphinx_rtd_theme'
 

GENERATE DOCS

sphinx­-apidoc -o docs/s­ource projec­t_dir
Generates automa­tically rst files for each module
make html
Build the html files with docume­ntation
xcopy build\html .
Copy files for publishing on github
sphinx­-apidoc needs to be rerun if the new module is added
       
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

            Python 3 Cheat Sheet by Finxter