Documentation
This template does not include a documentation setup, but it is very important for most projects (at least it should be) to have a documentation site, especially if you are not working alone. Here are the options I would suggest for setting up a documentation, recently I tend to favor the first one.
- Mkdocs with the Material theme
- Sphinx with the Furo theme
There is a chance that in the future I will include the docs directly in the template but for now here is a quick guide to configure mkdocs with the material theme:
Installation and configurations¶
Copy the configuration below into your pyproject.toml
file under the [tool.poetry.dependencies]
section.
1 2 3 4 5 6 7 8 |
|
Install the new dependencies.
1 |
|
Create your new mkdocs site.
1 |
|
Update the mkdocs.yml
file to specify the material theme, your configuration should look like this:
1 2 3 |
|
Run the documentation site locally
1 |
|
If you noticed, the dependencies added above via the section [tool.poetry.group.docs.dependencies]
include more than just
mkdocs and the material theme, specifically :
- mkdocs-material-extensions: Markdown extension resources for MkDocs for Material
- mkdocs-include-markdown-plugin: Include other markdown files in your mkdocs site
For a complete example of how I configure them in projects, see this configuration file.
Deploy your documentation¶
Mkdocs can turn your documentation into a static site that you can host anywhere, netlify, github pages, etc.
To build your site, run the command below and you will have a new site
directory at the root of your project:
1 |
|
This folder contains everything that is necessary to deploy your static site.
If you choose the github pages route, you can automate the process with github actions,
the official mkdocs-material documentation explains how to do it.
To use github actions, you will probably need a requirements.txt
file, you can generate one with only what is needed
to build the docs with the command below.
1 |
|
Read the mkdocs and mkdocs-material docs for more advanced configurations and details on what is possible.