Skip to content

Commit 8b096d0

Browse files
committed
🔧 Template: Add Read the Docs deployment for MkDocs
Basic configuration from the RTD documentation: https://docs.readthedocs.com/platform/stable/intro/mkdocs.html We just fix the Python version to 3.13 for more deterministic builds. We add the option to the corresponding `copier` question, but only in case MkDocs is selected for the documentation engine.
1 parent faa163c commit 8b096d0

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Template for Python packages based on [`copier`](https://copier.readthedocs.io/e
1010
* 📚 **Documentation**: Document your package in [MyST](https://mystmd.org/) or [MkDocs](https://www.mkdocs.org/).
1111
* 🧹 **Pre-commit**: Format and lint your code with [Ruff](https://docs.astral.sh/ruff/).
1212
* ⚙️ **GitHub Actions**:
13-
* Deploy documentation to [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).
13+
* Deploy documentation to [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site) or [Read the Docs](https://about.readthedocs.com/).
1414
* Run pre-commit checks and tests on every pull request.
1515

1616
## Usage

copier.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ docs:
1919
doc_deploy:
2020
type: str
2121
help: 'Where do you want to deploy your documentation?'
22-
choices:
22+
choices: |
2323
- nowhere
2424
- github
25+
{%- if docs == 'mkdocs' %}
26+
- rtd
27+
{%- endif %}
2528
default: nowhere
2629

2730
_subdirectory: template

docs/index.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ A `copier`-based template for Python packages.
55
## Features
66

77
* 📦 **Package management**: Test, build, and deploy your package with [Hatch](https://hatch.pypa.io/) environments.
8-
* 📚 **Documentation**: Document your package with [MyST](https://mystmd.org/) or [MkDocs](https://www.mkdocs.org/).
8+
* 📚 **Documentation**: Document your package in [MyST](https://mystmd.org/) or [MkDocs](https://www.mkdocs.org/).
99
* 🧹 **Pre-commit**: Format and lint your code with [Ruff](https://docs.astral.sh/ruff/).
1010
* ⚙️ **GitHub Actions**:
11-
* Deploy documentation to [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).
11+
* Deploy documentation to [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site) or [Read the Docs](https://about.readthedocs.com/).
1212
* Run pre-commit checks and tests on every pull request.
1313

1414
## Usage
@@ -21,3 +21,16 @@ copier copy https://github.com/mbercx/python-copier <package_name>
2121
```
2222

2323
And answer the questions to generate a new Python package.
24+
25+
## Next steps
26+
27+
After copying the template, you might still have to do some additional configuration.
28+
29+
### Deploy documentation
30+
31+
#### Read the Docs
32+
33+
1. Push your code to GitHub.
34+
2. Go to [Read the Docs](https://readthedocs.org/) (RTD) and [import your project](https://docs.readthedocs.com/platform/stable/tutorial/index.html#importing-the-project-to-read-the-docs).
35+
The build will use the included `.readthedocs.yaml` automatically.
36+
3. Set the RTD settings to [build from GitHub pull requests](https://docs.readthedocs.com/platform/stable/tutorial/index.html#triggering-builds-from-pull-requests).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-24.04"
5+
tools:
6+
python: "3.13"
7+
jobs:
8+
pre_install:
9+
- pip install mkdocs-material
10+
11+
mkdocs:
12+
configuration: mkdocs.yml

0 commit comments

Comments
 (0)