Skip to content

Commit 1374e2a

Browse files
update docs and README
1 parent 0ab8766 commit 1374e2a

File tree

7 files changed

+50
-54
lines changed

7 files changed

+50
-54
lines changed

README.md

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
55

6+
7+
68
# python-project-template — showcasing good software practices
79
The library provides a small dependence-free Calculator API (Operation, OperationRegistry, Calculator) that can register and compose simple mathematical operations.
810
This simple code is used to showcase some good coding practices.
@@ -22,50 +24,48 @@ This simple code is used to showcase some good coding practices.
2224

2325
- **Argument validation** with type annotations and runtime checking using the ``typing`` module.
2426
- **Consistent error messages** for invalid operations and inputs via custom ``Exceptions``.
25-
- **Unit tests** with ``pytest``. Global testing variables set in :file:`tests/convtest.py`.
27+
- **Unit tests** with ``pytest``. Global testing variables set in `tests/convtest.py`.
2628
- **Example notebooks and scripts** for demonstration and exploration.
2729
- **Google-style documentation** generated with ``sphinx``.
28-
- **Pre-commit routine** configured in :file:`.pre-commit-config.yaml`:
30+
- **Pre-commit routine** configured in `.pre-commit-config.yaml`:
2931

3032
- Code formatting with ``black``
3133
- Linting with ``ruff-pre-commit``
3234
- Type checking with ``mypy``
3335
- Additional checks and fixes (trailing whitespace removal, enforcing empty line at EOF, YAML syntax checks, blocking large files) via ``pre-commit-hooks``
3436

35-
-- **Modern packaging** and easy installation using :file:`pyproject.toml`.
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-
- **Automatic documentation deployment** to GitHub Pages with GitHub Actions. Setup in :file:`.github/workflows/docs.yml` [TODO].
37+
- **Modern packaging** and easy installation using `pyproject.toml`.
38+
- **Automated test suite and coverage reporting** integrated with GitHub Actions; coverage reports can be published to GitHub Pages. Setup in `.github/workflows/tests.yml`.
39+
- **Automatic documentation build and deployment** to GitHub Pages with GitHub Actions. Setup in `.github/workflows/docs.yml`.
3840
- **Easy contribution workflow** for new features and improvements.
3941

4042
## Installation
4143

4244
Clone the repository, create a virtual environment (recommended), and install dependencies and an editable installation of `python-project-template`:
4345

4446
```bash
45-
git clone <repo-url>
47+
git clone <https://github.com/andreascaglioni/python-project-template>
4648
cd python-project-template
4749
python3 -m venv .venv
4850
source .venv/bin/activate
4951
python -m pip install --upgrade pip setuptools wheel
5052
pip install -e ".[dev]"
5153
```
5254

53-
This installs the package in editable mode and the development extras (pytest, pre-commit, formatting and linting tools) so you can run tests and linters.
54-
5555
## Quick usage
5656

5757
The following is a quick example for the Calculator API.
5858

5959
```python
6060
from python_project_template import default_calculator, Operation
6161

62-
# Create a default calculator (pre-populated with common ops)
62+
# Create a default calculator (pre-populated with common operations)
6363
calc = default_calculator()
6464

65-
# Apply an operation
65+
# Apply an addition operation
6666
print(calc.apply('add', 2, 3)) # -> 5
6767

68-
# Compose unary operations
68+
# Compose unary operations into a Callable
6969
f = calc.compose(['neg', 'sqr'])
7070
print(f(3)) # -> 9
7171

@@ -86,11 +86,9 @@ print(calc.apply('inc', 4)) # -> 5
8686

8787
For detailed documentation, please visit our [GitHub Pages](https://andreascaglioni.github.io/your-repo-name/).
8888

89-
If you want to build and deploy the docs yourself via GitHub Actions, see `docs/README_DOCS_DEPLOY.md` for configuration and setup steps.
90-
9189
## Running tests
9290

93-
Run the full test suite with coverage:
91+
Run the full PyTest test suite with coverage:
9492

9593
```bash
9694
pytest -q --cov=python_project_template --cov-report=term --cov-report=html
@@ -102,28 +100,24 @@ Open `htmlcov/index.html` to view the coverage report.
102100

103101
```
104102
src/python_project_template/ # Core library package
105-
- calculator.py # Calculator API
106-
- operations.py # Built-in operations
107-
- registry.py # Operation registry
108-
- exceptions.py # Custom error types
109-
- utils.py # Utility functions
110-
experiments/ # Example scripts
111-
notebooks/ # Jupyter notebooks
103+
calculator.py # Calculator API
104+
operations.py # Built-in operations
105+
registry.py # Operation registry
106+
exceptions.py # Custom error types
107+
utils.py # Utility functions
108+
examples/ # Example usage of API
112109
tests/ # Test suite
113-
docs/ # Documentation
114-
.github/
115-
workflows/
116-
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
117-
docs.yml # GitHub Actions workflow for automated documentation and deployment
118-
pyproject.toml # Build/config file
119-
README.md # Project overview
120-
LICENSE # License info
110+
docs/ # Documentation (Sphinx source)
111+
.github/workflows/ # CI workflows (tests, docs)
112+
pyproject.toml # Project configuration and packaging
113+
README.md # This file
114+
LICENSE # License text
121115
CITATION.cff # Citation metadata
122116
```
123117

124118
## Contributing
125119

126-
Contributions are welcome. A quick workflow:
120+
Contributions are welcome. Typical workflow:
127121

128122
```bash
129123
git checkout -b feat/your-feature
@@ -134,16 +128,13 @@ git push --set-upstream origin feat/your-feature
134128
# open a PR
135129
```
136130

137-
### Developer notes
138-
- Use `pip install -e .[dev]` to get dev tools (pre-commit, black, ruff, mypy).
139-
- Run `pre-commit run --all-files` before committing.
140-
- CI runs tests on Ubuntu for Python 3.9–3.12 and uploads HTML coverage.
131+
Run `pip install -e .[dev]` to get development tools (pre-commit, black, ruff, mypy, pytest, ...).
132+
The pre-commit routine is called with `pre-commit run --all-files` before committing.
141133

142134
## License
143135

144136
This project is licensed under the MIT License — see the `LICENSE` file.
145137

146138
## Questions
147139

148-
If you have questions or want help extending the project (docs, CI, or
149-
examples), open an issue or drop a message in the repo.
140+
If you have questions or want help extending the project (docs, CI, or examples), open an issue or drop a message in the repository.

docs/appendix.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ This project is licensed under the MIT License — see the ``LICENSE`` file.
2727
Questions
2828
---------
2929

30-
If you have questions or want help extending the project (docs, CI, or examples),
31-
open an issue or create a discussion in the repository.
30+
If you have questions or want help extending the project (docs, CI, or examples), open an issue or drop a message in the repository.

docs/features.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ This code is used to showcase a number of good software practices:
77
- Consistent error messages for invalid operations and inputs via custom ``Exceptions``
88
- Unit tests with ``pytest``. Use :file:`tests/convtest.py` to set global testing variables
99
- Example notebooks and scripts
10-
- Google-style documentation with ``sphinx``
10+
- Google-style documentation generated with ``sphinx``
1111
- Pre-commit routine set up in file :file:`.pre-commit-config.yaml`. It includes:
1212

1313
- Formatting with ``black``
1414
- Linting with ``ruff`` via pre-commit
1515
- 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``
16+
- Additional checks and fixes (trailing whitespace removal, enforcing empty line at EOF, YAML syntax checks, blocking large files) via ``pre-commit-hooks``
1717

1818
- Modern packaging, easy installation, and project settings with :file:`pyproject.toml`
1919
- 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`
21-
- Easy contribution workflow.
20+
- Automatic documentation build and deployment to `GitHub Pages` with GitHub Actions. Setup in :file:`.github/workflows/docs.yml`
21+
- Easy contribution workflow for new features and improvements.

docs/installation.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ Clone the repository, create a virtual environment (recommended), and install de
55

66
.. code-block:: bash
77
8-
git clone <repo-url>
8+
git clone <https://github.com/andreascaglioni/python-project-template>
99
cd python-project-template
1010
python3 -m venv .venv
1111
source .venv/bin/activate
1212
python -m pip install --upgrade pip setuptools wheel
1313
pip install -e ".[dev]"
14+
15+
The editable installation automatically updates with the source code. It is useful for development because it allows skipping additional installations after source edits.

docs/structure.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ The project has the following directory structure:
1010
registry.py # Operation registry
1111
exceptions.py # Custom error types
1212
utils.py # Utility functions
13-
experiments/ # Example scripts
14-
notebooks/ # Jupyter notebooks
13+
exampoles/ # Example usage of API
1514
tests/ # Test suite
1615
docs/ # Documentation
17-
.github/
18-
workflows/
19-
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
20-
docs.yml # GitHub Actions workflow for automated documentation and deployment
21-
pyproject.toml # Build/config file
22-
README.md # Project overview
23-
LICENSE # License info
24-
CITATION.cff # Citation metadata
16+
.github/workflows/
17+
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
18+
docs.yml # GitHub Actions workflow for automated documentation and deployment
19+
pyproject.toml # Build/config file
20+
README.md # Project overview
21+
LICENSE # License info
22+
CITATION.cff # Citation metadata
23+
24+
25+
.. note::
26+
27+
Why is the module inside ``src/``? It prevents accidental imports from the working directory so your tests mirror real installs. This is a widely recommended pattern in the `Python Packaging User Guide <https://packaging.python.org/en/latest/tutorials/packaging-projects/#src-layout>`_.

docs/tests.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Test-driven development is a software development approach where tests are writt
1313
Running the tests manually
1414
--------------------------
1515

16-
Run the full pytest test suite with coverage:
16+
Run the full PyTest test suite with coverage:
1717

1818
.. code-block:: bash
1919

docs/usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The following is a quick example for the Calculator API. It shows how to:
1212
from python_project_template import default_calculator, Operation
1313
1414
calc = default_calculator()
15+
1516
print(calc.apply('add', 2, 3)) # -> 5
1617
1718
f = calc.compose(['neg', 'sqr'])

0 commit comments

Comments
 (0)