Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
23a11a3
feat: support mkdocs and add automatic docs deployment for GitHub Pages
SimonJasansky Aug 25, 2025
d63c316
feat: address PR comments
SimonJasansky Aug 27, 2025
5e8a41e
Update README.md
SimonJasansky Sep 1, 2025
a632e45
Update template/README.md.jinja
SimonJasansky Sep 2, 2025
ff90ea0
Update uv version
SimonJasansky Sep 2, 2025
517b056
Update mkdocs.yml
SimonJasansky Sep 2, 2025
a697fba
update index.md
SimonJasansky Sep 2, 2025
c4d2932
feat: remove documentation_tool from copier questions and always supp…
SimonJasansky Sep 2, 2025
a17abf1
fix: rename docs folder
SimonJasansky Sep 2, 2025
a9ea4b1
fix: update README
SimonJasansky Sep 2, 2025
ab9cdce
Apply suggestion from @lsorber
SimonJasansky Sep 5, 2025
02765c3
feat: address PR comments
SimonJasansky Sep 5, 2025
c88f0f0
Update template/{% if ci == 'github' %}.github{% endif %}/workflows/d…
SimonJasansky Sep 9, 2025
bbdcf7c
Update template/mkdocs.yml.jinja
SimonJasansky Sep 9, 2025
c1d23c8
Update template/mkdocs.yml.jinja
SimonJasansky Sep 9, 2025
bcf2e54
Update template/mkdocs.yml.jinja
SimonJasansky Sep 9, 2025
c36a018
Update template/pyproject.toml.jinja
SimonJasansky Sep 9, 2025
5c3ecb8
Update README.md
SimonJasansky Sep 9, 2025
27b4e64
fix(docs.yml): yaml syntax error
SimonJasansky Sep 9, 2025
ca92a3c
feat(mkdocs.yml): strip trailing slashes when parsing project_url
SimonJasansky Sep 9, 2025
61a41a3
feat: move API reference from dedicated folder /reference to file ref…
SimonJasansky Sep 9, 2025
8130999
Update template/pyproject.toml.jinja
SimonJasansky Sep 10, 2025
f84eae7
Update template/{% if ci == 'github' %}.github{% endif %}/workflows/d…
SimonJasansky Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ A modern [Copier template](https://github.com/copier-org/copier) for scaffolding
- ♻️ Continuous integration with [GitHub Actions](https://docs.github.com/en/actions) or [GitLab CI/CD](https://docs.gitlab.com/ee/ci/)
- 🧪 Test coverage with [Coverage.py](https://github.com/nedbat/coveragepy)
- 🧰 Dependency updates with [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates)
- 📚 Documentation with [MkDocs](https://github.com/mkdocs/mkdocs)

## ✨ Using

Expand Down Expand Up @@ -91,6 +92,19 @@ To migrate a project from Cookiecutter to Copier, follow these steps:

5. Create a PR from your branch, review it, and merge it!

### Build and publish your Python project's docs

To build and serve your Python project's docs, run:

```sh
poe docs --serve
```

If your project is on GitHub, your docs will be published automatically to GitHub Pages every time you update the default branch. You can view the docs by clicking on the ![Documentation](https://img.shields.io/static/v1?label=Documentation&message=View&color=blue&logo=readme&logoColor=white)] badge in your project's README.

> [!TIP]
> Make sure to [configure the source of your project's GitHub Pages as GitHub Actions in your project settings](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow) to allow the GitHub Actions workflow to publish your docs.

## Contributing

<details>
Expand Down
5 changes: 5 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ project_name_kebab_case:
project_name_snake_case:
when: false
default: "{{ project_name | lower | replace(' ', '_') }}"

documentation_url:
when: false
default: "{% if ci == 'github' %}https://{{ project_url.rstrip('/').split('/')[-2] }}.github.io/{{ project_url.rstrip('/').split('/')[-1] }}{% else %}{{ project_url }}{% endif %}"

3 changes: 3 additions & 0 deletions template/.gitignore.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ notebooks/
# mise
mise.local.toml

# MkDocs
site/

# mypy
.dmypy.json
.mypy_cache/
Expand Down
2 changes: 1 addition & 1 deletion template/README.md.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE3IDE2VjdsLTYgNU0yIDlWOGwxLTFoMWw0IDMgOC04aDFsNCAyIDEgMXYxNGwtMSAxLTQgMmgtMWwtOC04LTQgM0gzbC0xLTF2LTFsMy0zIi8+PC9zdmc+)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url={{ project_url }}){% if ci == 'github' %} [![Open in GitHub Codespaces](https://img.shields.io/static/v1?label=GitHub%20Codespaces&message=Open&color=blue&logo=github)](https://github.com/codespaces/new/{{ project_url.replace("https://github.com/", "") }}){% endif %}
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE3IDE2VjdsLTYgNU0yIDlWOGwxLTFoMWw0IDMgOC04aDFsNCAyIDEgMXYxNGwtMSAxLTQgMmgtMWwtOC04LTQgM0gzbC0xLTF2LTFsMy0zIi8+PC9zdmc+)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url={{ project_url }}){% if ci == 'github' %} [![Open in GitHub Codespaces](https://img.shields.io/static/v1?label=GitHub%20Codespaces&message=Open&color=blue&logo=github)](https://github.com/codespaces/new/{{ project_url.replace("https://github.com/", "") }}){% endif %}{% if ci == 'github' %} [![Documentation](https://img.shields.io/static/v1?label=Documentation&message=View&color=blue&logo=readme&logoColor=white)]({{ documentation_url }}){% endif %}

# {{ project_name }}

Expand Down
3 changes: 3 additions & 0 deletions template/docs/index.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ project_name }}

{{ project_description }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reference

::: {{ project_name_snake_case }}
41 changes: 41 additions & 0 deletions template/mkdocs.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
site_name: {{ project_name }}
site_description: {{ project_description }}
site_url: {{ documentation_url }}
repo_url: {{ project_url }}
repo_name: {{ project_url.rstrip('/').split('/')[-2:] | join('/') }}
{%- if typing == 'strict' %}

strict: true

validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn
anchors: warn
{%- endif %}

theme:
name: material

nav:
- Home: index.md
{%- if project_type == 'package' %}
- Reference: reference.md

watch:
- src
{%- endif %}

plugins:
- search
{%- if project_type == 'package' %}
- mkdocstrings:
handlers:
python:
options:
docstring_style: numpy
{%- endif %}

markdown_extensions:
- pymdownx.highlight
- pymdownx.superfences
43 changes: 20 additions & 23 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ source = "{{ project_url }}"
changelog = "{{ project_url.rstrip('/') }}/{% if ci == 'gitlab' %}-/{% endif %}blob/main/CHANGELOG.md"
{%- endif %}
releasenotes = "{{ project_url.rstrip('/') }}/{% if ci == 'gitlab' %}-/{% endif %}releases"
documentation = "{{ project_url }}"
documentation = "{{ documentation_url }}"
issues = "{{ project_url.rstrip('/') }}/{% if ci == 'gitlab' %}-/{% endif %}issues"

[dependency-groups] # https://docs.astral.sh/uv/concepts/projects/dependencies/#development-dependencies
Expand All @@ -49,8 +49,9 @@ dev = [
"ipython (>=8.18.0)",
"ipywidgets (>=8.1.2)",
"mypy (>=1.14.1)",
"pdoc (>=15.0.1)",
"mkdocs-material (>=9.5.21)",
{%- if project_type == 'package' %}
"mkdocstrings[python] (>=0.26.2)",
"poethepoet (>=0.32.1)",
{%- endif %}
"pre-commit (>=4.0.1)",
Expand Down Expand Up @@ -154,6 +155,23 @@ convention = "numpy"
type = "simple"

[tool.poe.tasks]

[tool.poe.tasks.docs]
help = "Build or serve the documentation"
shell = """
if [ $serve ]
then {
mkdocs serve
} else {
mkdocs build
} fi
"""

[[tool.poe.tasks.docs.args]]
help = "Serve the documentation locally with live reload"
type = "boolean"
name = "serve"
options = ["--serve"]
{%- if with_fastapi_api %}

[tool.poe.tasks.serve]
Expand Down Expand Up @@ -207,27 +225,6 @@ type = "simple"
cmd = "echo 'Serving app (placeholder)...'"
{%- endif %}

[tool.poe.tasks.docs]
help = "Generate this {{ project_type }}'s docs"
cmd = """
pdoc
--docformat $docformat
--output-directory $outputdirectory
{{ project_name_snake_case }}
"""

[[tool.poe.tasks.docs.args]]
help = "The docstring style (default: numpy)"
name = "docformat"
options = ["--docformat"]
default = "numpy"

[[tool.poe.tasks.docs.args]]
help = "The output directory (default: docs)"
name = "outputdirectory"
options = ["--output-directory"]
default = "docs"

[tool.poe.tasks.lint]
help = "Lint this {{ project_type }}"
cmd = """
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Documentation

on:
push:
branches: [main]

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ "{{" }} steps.deployment.outputs.page_url {{ "}}" }}

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Build docs
run: uv run mkdocs build

- name: Configure GitHub Pages
uses: actions/configure-pages@v5

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: site

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Loading