You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ This simple code is used to showcase some good coding practices.
32
32
- Type checking with ``mypy``
33
33
- Additional checks and fixes (trailing whitespace removal, enforcing empty line at EOF, YAML syntax checks, blocking large files) via ``pre-commit-hooks``
34
34
35
-
-**Modern packaging** and easy installation using ``pyproject.toml``.
35
+
--**Modern packaging** and easy installation using :file:`pyproject.toml`.
36
36
-**Automated test suite and coverage reporting** integrated with GitHub Actions; coverage reports can be published to GitHub Pages. Setup in :file:`.github/workflows/tests.yml`.
37
37
-**Automatic documentation deployment** to GitHub Pages with GitHub Actions. Setup in :file:`.github/workflows/docs.yml`[TODO].
38
38
-**Easy contribution workflow** for new features and improvements.
This page explains how the repository builds the Sphinx documentation and publishes
5
+
the generated HTML to GitHub Pages using GitHub Actions.
6
+
7
+
The workflow does the following:
8
+
9
+
- Whenever a commit is pushed to `main`, the workflow checks out the repository (manual dispatch is also supported).
10
+
- Sets up Python and installs the ``docs`` dependencies from :file:`pyproject.toml`.
11
+
- Builds HTML with ``sphinx-build`` into ``docs/_build/html``.
12
+
- Uploads the built HTML as a Pages artifact and deploys it to GitHub Pages.
13
+
14
+
Repository setup (one-time)
15
+
---------------------------
16
+
1. Ensure the repository has GitHub Pages enabled for the ``gh-pages`` site (no manual branch required when using the Pages actions). In repository Settings → Pages you should see the site status after the first successful run.
17
+
2. No secret is required. The workflow uses the repository's built-in ``GITHUB_TOKEN`` permissions to publish pages.
18
+
19
+
Local testing
20
+
-------------
21
+
To build the docs locally (recommended before pushing):
22
+
23
+
.. code-block:: bash
24
+
25
+
# create and activate a venv
26
+
python -m venv .venv
27
+
source .venv/bin/activate
28
+
python -m pip install --upgrade pip
29
+
# install docs dependencies
30
+
pip install -e ".[docs]"
31
+
# build
32
+
cd docs
33
+
sphinx-build -b html -a -E -W -T . _build/html
34
+
35
+
Autosummary and generated files
36
+
-------------------------------
37
+
- ``autosummary_generate = True`` is enabled in ``docs/conf.py``, so Sphinx will generate the ``_autosummary`` pages during the build.
38
+
- Best practice: do NOT commit generated files (``docs/_build``, ``docs/_autosummary``) to the repository. Keep them in ``.gitignore`` and let CI produce the HTML. If you plan to serve source HTML directly from the ``docs/`` folder (without a build step), then you'd need to commit generated files — but the current workflow builds on CI and deploys the result, so committing generated files is unnecessary.
39
+
40
+
Troubleshooting
41
+
---------------
42
+
- If builds fail due to missing packages, ensure :file:`pyproject.toml` contains the correct ``docs`` extras and that ``pip install -e ".[docs]"`` succeeds.
43
+
- If the site does not appear after the workflow succeeds, check Settings → Pages to ensure the site is not blocked by organization policy.
44
+
45
+
That's it — the workflow will publish your Sphinx docs automatically when you push to ``main``.
Good documentation is essential for code sustainability. It ensures that others can understand, use, and maintain the project, especially if the original developer leaves. Adopting a consistent style, such as Google (used here) or NumPy, helps keep docs clear and accessible.
5
+
6
+
To build the documentation for this project, follow these steps:
7
+
8
+
1. Ensure all dependencies for documentation generation are installed, for example with ``pip install -e ".[docs]"``.
9
+
2. Run the documentation build command (for example, ``make html``).
10
+
3. Review the generated HTML in ``docs/_build/html``.
This code is used to showcase a number of good software practices:
5
+
6
+
- Argument validation with type annotations and runtime checking using the ``typing`` module
7
+
- Consistent error messages for invalid operations and inputs via custom ``Exceptions``
8
+
- Unit tests with ``pytest``. Use :file:`tests/convtest.py` to set global testing variables
9
+
- Example notebooks and scripts
10
+
- Google-style documentation with ``sphinx``
11
+
- Pre-commit routine set up in file :file:`.pre-commit-config.yaml`. It includes:
12
+
13
+
- Formatting with ``black``
14
+
- Linting with ``ruff`` via pre-commit
15
+
- Type checking with ``mypy``
16
+
- Additional checks and fixes (remove trailing whitespace, ensure one empty line at end of file, YAML syntax checks, prevent committing large files) with ``pre-commit-hooks``
17
+
18
+
- Modern packaging, easy installation, and project settings with :file:`pyproject.toml`
19
+
- Automated test suite and coverage reporting integrated with `GitHub Actions`; coverage reports can be published to `GitHub Pages`. See :file:`.github/workflows/tests.yml`
20
+
- Automatic build and deployment of the documentation to `GitHub Pages` with GitHub Actions. See :file:`.github/workflows/docs.yml`
**python-project-template is a minimal Python project aimed at demonstrating good coding practices.**
5
5
6
-
The library provides a small dependence-free Calculator API (Operation, OperationRegistry, Calculator) that can register and compose simple mathematical operations.
7
-
This simple code is used to showcase some good coding practices:
8
-
9
-
- Argument validation with type annotation and checking with the ``typing`` module
10
-
- Consistent error messages for invalid operations and inputs through custom ``Exceptions``
11
-
- Unit tests unit with ``pytest``. Use of :file:`tests/convtest.py` to set global testing variables
12
-
- Example notebooks and scripts
13
-
- Google-style documentation with ``sphinx``
14
-
- Pre-commit routine set up in file :file:`.pre-commit-config.yaml`. It includes:
15
-
16
-
- Formatting with ``black``
17
-
- Linting with ``ruff-pre-commit``
18
-
- Type checking with ``mypy``
19
-
- Additional checks and fixes (remove trailing white spaces, ensure one empty line at end of the file, YAML files syntax check, prevent committing large files) with ``pre-commit-hooks``
20
-
21
-
- Modern packaging, easy installation, and project settings with ``pyproject.toml``
22
-
- Automated test suite and coverage reporting integrated with `GitHub Actions`; coverage reports can be published to `GitHub Pages`. Setup through file :file:`.github/workflows/tests.yml`
23
-
- Automatic compilation and deployment of the documentation to `GitHub Pages` with `Github-Actions`. Setup through file :file:`.github/workflows/docs.yml` [TODO]
24
-
- Easy contribution workflow.
25
-
26
-
27
-
Installation
28
-
------------
29
-
30
-
Clone the repository, create a virtual environment (recommended), and install dependencies and editable installation of ``python-project-template``:
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
106
-
docs.yml # GitHub Actions workflow for automated documentation and deployment
107
-
pyproject.toml # Build/config file
108
-
README.md # Project overview
109
-
LICENSE # License info
110
-
CITATION.cff # Citation metadata
111
-
112
-
113
-
Contributing
114
-
------------
115
-
116
-
A quick workflow:
117
-
118
-
.. code-block:: bash
119
-
120
-
git checkout -b feat/your-feature
121
-
# make changes
122
-
pytest
123
-
git add -A && git commit -m "Add feature"
124
-
git push --set-upstream origin feat/your-feature
125
-
126
-
Use ``pip install -e .[dev]`` to get dev tools (pre-commit, black, ruff, mypy)
127
-
and run ``pre-commit run --all-files`` before committing.
128
-
129
-
130
-
License
131
-
-------
132
-
133
-
This project is licensed under the MIT License — see the ``LICENSE`` file.
134
-
135
-
136
-
Questions
137
-
---------
138
-
139
-
If you have questions or want help extending the project (docs, CI, or examples),
140
-
open an issue or drop a message in the repository.
141
-
6
+
The library provides a small dependency-free Calculator API (Operation, OperationRegistry, Calculator) that can register and compose simple mathematical operations.
7
+
This code is used to showcase a number of good software practices. See the next page for a detailed list.
0 commit comments