5.4. Creating new documentation with Sphinx¶
This section describes how sphinx documentation can be created for your project. Typically this documentation would be generated within a code repository.
Setting up a Sphinx project¶
Follow the quick-start instructions on the official sphinx documentation page
During this process, it will ask
Separate source and build directories (y/n). Select yes.You can now add new reST source files and place them in the
docs/sourcefolder.Add the filenames of these new source file to the
index.rstfile in thedocs/sourcefolder.
To make this process easier, we have provided a template software project on Github that you can use to get started. Download and copy the docs folder from this repository
Building Sphinx documentation¶
From the command line¶
In a terminal, change directory to the folder where the sphinx documentation was generated (ie the
docsfolder):
cd path/to/docs
Enter the following command.
make html
You can then open the html version of the documentation by opening
/path/to/docs/build/index.htmlin your browser of choice e.g. Google Chrome.
From IDEs¶
For more information on how to build documentation from IDEs such as PyCharm, see the Updating documentation Section of this tutorial.
5.5. FAQs¶
This section provides documentation on how to use reStructuredText and Markdown with Sphinx.
reStructuredText with Sphinx FAQ¶
- 1. How to comment?
- 2. How to display source code in your documentation?
- 3. How to reference specific coding terms?
- 4. How to hyperlink and cross-reference?
- 5. How to allow the user to download specific source files?
- 6. How to create tables?
- 7. How to add notes and warnings?
- 8. How to number sections?
- 9. How to add images?
- 10. How to add a bibiliography?
- 11. How to programmatically graphs/diagrams?