Creating documentation with Sphinx
Set up
Install Sphinx:
Generate the basic structure of Sphinx documentation. It is usually recommended to separate source and build directories.
Now we can build the HTML documentation with:
Note: .\make.bat html
is for Powershell. make html
for macOS, Linux or Windows command prompt
Serve with Python built-in HTTP server:
Using Markdown with Sphinx
Convert RST files to Markdown:
We can now delete the index.rst file.
In the Sphinx config.py
file we now need to add the following extension:
and install it:
Now we can build the HTML from the Markdown files.
Useful configurations
To monitor changes in the docs and rebuild the HTML we can use sphinx-autobuild
:
If you wish to include the README.md file in the docs, in the docs/source/index.md add the following directive:
```{include} ../../README.md
:relative-images:
```
To add a warning:
```{warning}
Warning text.
```
Other handy extensions:
Install another theme:
In the Sphinx config.py
:
Create a new page (usage.md
) next to the index.md
file. Link to a page:
Creating module pages automatically
Joback Method
=============
.. automodule:: chem_eng_kit.properties.joback
:members:
:exclude-members: _sum_group_property
Creating docstrings
Code blocks
def foo():
'''
.. highlight:: python
.. code-block:: python
res = aFunction(something, goes, in)
print(res.avalue)
'''
Inline code in reStructuredText:
Inline code in Markdown:
Math
Displayed math:
Inline math: