There are 2 sorts of docs you can generate with Sphinx:
- API docs based on docstrings
- docs based on restructured text
This shows you how to do the later, but it’s a start and you should be able to continue from here…
First, get Sphinx and the RTD theme, which looks nicer than the default one.
- pip install sphinx
- pip install sphinx_rtd_theme
Create a directory named source wherever you want the source for your docs to live. (e.g. C:\somewhere\docs\source). Next create a file called conf.py and put it into the source directory. This is the general config file for the docs you are building.
Example:
# -*- coding: utf-8 -*-
import sys
import os
import shlex
import sphinx_rtd_theme
project = u'Documentation of my Project'
author = u'Robert Kist'
version = '0.0.1'
release = '0.0.1'
basename = 'mysoftwaretool'
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.ifconfig',
'sphinx.ext.graphviz',
]
inheritance_graph_attrs = dict(rankdir="TB", size='""')
graphviz_output_format = 'svg'
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
language = None
exclude_patterns = []
pygments_style = 'sphinx'
todo_include_todos = True
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# html_static_path = ['_static']
html_show_sourcelink = False
html_show_sphinx = False
html_show_copyright = False
htmlhelp_basename = '%sdoc' % basename
latex_elements = {}
latex_documents = [
(master_doc, '%s.tex' % basename, u'%s Documentation' % basename,
author, 'manual'),
]
man_pages = [
(master_doc, basename, u'%s Documentation' % basename,
[author], 1)
]
texinfo_documents = [
(master_doc, basename, u'%s Documentation' % basename,
author, basename, 'One line description of project.',
'Miscellaneous'),
]
intersphinx_mapping = {'https://docs.python.org/': None}
Next create an index.rst file and put it into the source directory. This will be the starting page of your documentation. Example:
Hello World!
############
outside the source directory run this command. It will take read source/conf.py and process any RST .files in source. It will then create HTML output in output
C:\Python27\Scripts\sphinx-build.exe -b html source output