Skip to content

Commit 0b70e98

Browse files
committed
✨ Allow user to choose documentation tool
Currently the package template only offers MyST for the documentation generator tool. However, some users might prefer to use MkDocs for its simplicity and sleek look. Here we adapt the template to give users the option to select their preffered documentation tool. On the template package level, we remove the `default.docs` command, which copied the template and then served its documenation with `myst start`. Providing options for both MyST and MkDocs options will clutter the default environment with too many scripts, and serving the package documentation is also done easily after doing `hatch run copy`.
1 parent 4170da9 commit 0b70e98

File tree

7 files changed

+38
-9
lines changed

7 files changed

+38
-9
lines changed

copier.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ package_name:
22
type: str
33
help: 'What is the name of your Python package?'
44
default: '{{_folder_name }}'
5+
56
description:
67
type: str
78
help: 'Describe what your Python package is for.'
89
default: 'Python package'
910

11+
docs:
12+
type: str
13+
help: 'Which documentation engine do you prefer?'
14+
choices:
15+
- myst
16+
- mkdocs
17+
default: myst
18+
1019
_subdirectory: template
1120
_message_after_copy: |
1221
The `{{package_name}}` package has been created successfully!

docs/design.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,24 @@ This pattern has a few advantages:
3535

3636
## Documentation
3737

38-
We use [MyST Markdown](https://mystmd.org/) for our Python package documentation.
39-
We want to use a Markdown-based documentation tool for simplicity, avoiding Sphinx' reStructuredText format.
38+
The user can select which documentation engine they prefer.
39+
Some information on the two options is already provided below, this will be fleshed out more as both frameworks are tested more rigorously.
40+
41+
## MyST Markdown
42+
43+
[MyST Markdown](https://mystmd.org/) is a Markdown-based documentation tool that avoids Sphinx' reStructuredText format while preserving most of its power.
4044
The main reason to use this over [MkDocs](https://www.mkdocs.org/) to test the Jupyter notebook integration, especially the "executable content".
4145
MyST is also easy to integrate with Sphinx, which has a lot of powerful tools, especially for scientific software.
4246

47+
## MkDocs
48+
49+
[MkDocs](https://www.mkdocs.org/) is another Markdown-based documentation tool that focusses even more on simplicity.
50+
Some features:
51+
52+
1. Very simple to build and write, not too much faff.
53+
1. Static pages, easy to host.
54+
1. Sleek look, using [Material for MkDocs](https://github.com/squidfunk/mkdocs-material).
55+
4356
## DevOps
4457

4558
This template includes development automation tools that ensure code quality, consistency, and developer efficiency.

docs/developer.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Other scripts for the default environment:
2626

2727
* `check`: Copy/Update the template in the `.tmp` directory and check the rendered files by linting them with `hatch fmt -l`.
2828
* `clean`: Remove the `.tmp` directory and any Ruff caches.
29-
* `docs`: Copy/Update the template in the `.tmp` directory and serve the documentation with `myst start`.
3029
* `install`: Copy/Update the template in the `.tmp` directory and install it with `uv pip install`.
3130

3231
## Documentation

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ scripts.check = [
1515
"copier copy --vcs-ref=HEAD . .tmp/py-package -f",
1616
"hatch fmt -l --check .tmp/py-package",
1717
]
18-
scripts.docs = [
19-
"copier copy --vcs-ref=HEAD . .tmp/py-package -f",
20-
"cd .tmp/py-package/docs && myst start",
21-
]
2218
scripts.clean = [
2319
"ruff clean",
2420
"rm -rf .tmp",
2521
]
2622

27-
2823
[tool.hatch.envs.docs]
2924
detached = true
3025
dependencies = [

template/docs/myst.yml.jinja renamed to template/docs/{% if docs == 'myst' %}myst.yml{% endif %}.jinja

File renamed without changes.

template/pyproject.toml.jinja

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@ classifiers = [
2424
[tool.hatch.version]
2525
path = "src/{{ package_name.lower().replace('-', '_') }}/__about__.py"
2626

27-
27+
{% if docs == 'myst'-%}
2828
[tool.hatch.envs.docs]
2929
dependencies = [
3030
"mystmd"
3131
]
3232
scripts.build = "cd docs && myst build"
3333
scripts.start = "cd docs && myst start"
34+
{%- endif -%}
3435

36+
{%- if docs == 'mkdocs' -%}
37+
[tool.hatch.envs.docs]
38+
dependencies = [
39+
"mkdocs",
40+
"mkdocs-material"
41+
]
42+
scripts.build = "mkdocs build --clean --strict"
43+
scripts.serve = "mkdocs serve --dev-addr localhost:8000"
44+
{%- endif %}
3545

3646
[tool.hatch.envs.precommit]
3747
dependencies = ["pre-commit"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
site_name: {{package_name}}
2+
theme:
3+
name: material

0 commit comments

Comments
 (0)