We use sphinx to build and readthedocs to host the documentation.
Sphinx is a documentation generator or a tool that translates a set of plain text source files into various output formats, automatically producing cross-references, indices, etc. That is, if you have a directory containing a bunch of reStructuredText or Markdown documents, Sphinx can generate a series of HTML files, a PDF file (via LaTeX), man pages and much more.
For more information access the documentation here.
It is a tool for automatic generation of Sphinx sources that, using the autodoc extension, document a whole package in the style of other automatic API documentation tools. For more information access the documentation here.
Here we will describe how to create a docs, configure the conf.py file and update the documentation.
- Install Sphinx!
pip install Sphinx
pip install pip install sphinx_rtd_theme
- First, make the directory docs with command
mkdir docs
- Run the following command
sphinx-apidoc -o docs pymove -full
Finish! Your documentation has been created! The generated files are of the extension .rst (reStructuredText). There are two main files:
-
index.rst: is the root of your documentation
-
conf.py: where are the dependencies and internal settings, such as the html theme, and imports and the path to the library.
In the file conf.py, include the following imports:
import os
import sys
And include the following code snippet, referring to the library path:
sys.path.append(os.path.join(os.path.dirname(__name__), '..'))
Now, you must:
- Describe project informations
- Configure extensions
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.todo',
'sphinx_rtd_theme'
]
- Configure theme html
html_theme = 'sphinx_rtd_theme'
and finish!
To generate the .html files, just access the docs folder, just run the following command:
make doc
2.4. Hospedando docs in Readthedocs
-
Log in to Readthedocs with your github account
-
Import the project/repository
-
Select the project and the branch where your project contains the documentation
-
Click on build project
-
After preparing the environment and finalizing the building process, you can see your project's documentation in view docs.
To update the documentation just run the following command and move
the generated files to the folder references/
.
sphinx-apidoc -f -o docs/references pymove pymove/tests/