From 2137b4f6d2bd8cdda10bf0c0b0b1cb7edbdad3e0 Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Tue, 1 Jul 2025 23:35:20 -0400 Subject: [PATCH] Add yardang option, fixes #57 --- copier.yaml | 5 ++++ ...% if add_docs %}docs.yaml{% endif %}.jinja | 23 +++++++++++++++++++ cpp/.gitignore.jinja | 3 ++- examples/cpp.yaml | 3 ++- examples/js.yaml | 3 ++- examples/jupyter.yaml | 1 + examples/python.yaml | 1 + examples/rust.yaml | 1 + ...% if add_docs %}docs.yaml{% endif %}.jinja | 23 +++++++++++++++++++ js/.gitignore.jinja | 3 ++- ...% if add_docs %}docs.yaml{% endif %}.jinja | 23 +++++++++++++++++++ jupyter/.gitignore.jinja | 3 ++- ...% if add_docs %}docs.yaml{% endif %}.jinja | 23 +++++++++++++++++++ python/.gitignore | 4 ++-- python/pyproject.toml.jinja | 10 ++++++++ ...% if add_docs %}docs.yaml{% endif %}.jinja | 23 +++++++++++++++++++ rust/.gitignore | 3 ++- 17 files changed, 147 insertions(+), 8 deletions(-) create mode 100644 cpp/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja create mode 100644 js/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja create mode 100644 jupyter/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja create mode 100644 python/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja create mode 100644 rust/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja diff --git a/copier.yaml b/copier.yaml index 2243b77..533e20f 100644 --- a/copier.yaml +++ b/copier.yaml @@ -65,3 +65,8 @@ python_version_primary: "3.12": value: "3.12" help: Primary version of Python to use in CI/CD + +add_docs: + type: bool + default: false + help: Add documentation using Yardang/Sphinx diff --git a/cpp/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/cpp/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..67455f3 --- /dev/null +++ b/cpp/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,23 @@ +name: Docs +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/cpp/.gitignore.jinja b/cpp/.gitignore.jinja index fa044b2..9ee22fb 100644 --- a/cpp/.gitignore.jinja +++ b/cpp/.gitignore.jinja @@ -129,8 +129,9 @@ dmypy.json .pyre/ # Documentation -docs/_build/ /site +index.md +docs/_build/ docs/api docs/index.md docs/html diff --git a/examples/cpp.yaml b/examples/cpp.yaml index b4b0426..17bc99d 100644 --- a/examples/cpp.yaml +++ b/examples/cpp.yaml @@ -1,5 +1,6 @@ --- -add_extension: cpp +add_docs: true +add_extension: cpp email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates project_description: A C++-Python project template diff --git a/examples/js.yaml b/examples/js.yaml index c77e0bd..a114e9b 100644 --- a/examples/js.yaml +++ b/examples/js.yaml @@ -1,5 +1,6 @@ --- -add_extension: js +add_docs: true +add_extension: js email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates project_description: A JavaScript-Python project template diff --git a/examples/jupyter.yaml b/examples/jupyter.yaml index ec411d8..336fd07 100644 --- a/examples/jupyter.yaml +++ b/examples/jupyter.yaml @@ -1,4 +1,5 @@ --- +add_docs: true add_extension: jupyter email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates diff --git a/examples/python.yaml b/examples/python.yaml index 39ede94..8110b09 100644 --- a/examples/python.yaml +++ b/examples/python.yaml @@ -1,4 +1,5 @@ --- +add_docs: true add_extension: python email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates diff --git a/examples/rust.yaml b/examples/rust.yaml index 605e569..a19c71d 100644 --- a/examples/rust.yaml +++ b/examples/rust.yaml @@ -1,4 +1,5 @@ --- +add_docs: true add_extension: rust email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates diff --git a/js/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/js/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..67455f3 --- /dev/null +++ b/js/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,23 @@ +name: Docs +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/js/.gitignore.jinja b/js/.gitignore.jinja index 5d4e82e..1a22309 100644 --- a/js/.gitignore.jinja +++ b/js/.gitignore.jinja @@ -125,8 +125,9 @@ dmypy.json .pyre/ # Documentation -docs/_build/ /site +index.md +docs/_build/ docs/api docs/index.md docs/html diff --git a/jupyter/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/jupyter/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..67455f3 --- /dev/null +++ b/jupyter/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,23 @@ +name: Docs +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/jupyter/.gitignore.jinja b/jupyter/.gitignore.jinja index 9e11bdf..01a2d4c 100644 --- a/jupyter/.gitignore.jinja +++ b/jupyter/.gitignore.jinja @@ -125,8 +125,9 @@ dmypy.json .pyre/ # Documentation -docs/_build/ /site +index.md +docs/_build/ docs/api docs/index.md docs/html diff --git a/python/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/python/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..67455f3 --- /dev/null +++ b/python/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,23 @@ +name: Docs +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/python/.gitignore b/python/.gitignore index ba3d5bc..20339c6 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -125,11 +125,11 @@ dmypy.json .pyre/ # Documentation -docs/_build/ /site +index.md +docs/_build/ docs/api docs/index.md -_template/labextension # Jupyter .ipynb_checkpoints diff --git a/python/pyproject.toml.jinja b/python/pyproject.toml.jinja index 2517fd4..546faa7 100644 --- a/python/pyproject.toml.jinja +++ b/python/pyproject.toml.jinja @@ -115,3 +115,13 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] + +{%- if add_docs %} + +[tool.yardang] +title = "{{ project_name }}" +root = "README.md" +pages = [] +use-autoapi = true + +{% endif -%} diff --git a/rust/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja b/rust/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja new file mode 100644 index 0000000..67455f3 --- /dev/null +++ b/rust/.github/workflows/{% if add_docs %}docs.yaml{% endif %}.jinja @@ -0,0 +1,23 @@ +name: Docs +on: + push: + branches: + - main + workflow_dispatch: +permissions: + contents: write +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-ext/python/setup@main + - uses: actions-ext/node/setup@main + - run: uv pip install . + - run: uv pip install yardang + - run: yardang build + - uses: peaceiris/actions-gh-pages@v4 + with: + publish_branch: gh-pages + github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + publish_dir: docs/html diff --git a/rust/.gitignore b/rust/.gitignore index 1504421..5254ee8 100644 --- a/rust/.gitignore +++ b/rust/.gitignore @@ -125,8 +125,9 @@ dmypy.json .pyre/ # Documentation -docs/_build/ /site +index.md +docs/_build/ docs/api docs/index.md docs/html