Skip to content

Commit b76ef16

Browse files
mkumar73Copilot
andcommitted
docs: update contributing guide with just commands and pre-push workflow
Co-authored-by: Copilot <copilot@github.com>
1 parent 69decf9 commit b76ef16

2 files changed

Lines changed: 90 additions & 23 deletions

File tree

docs/contributing.md

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ cd DeepTab
4848
4949
poetry install
5050
51-
poetry run pre-commit install
51+
poetry run pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push
5252
```
5353

54-
If you need to update the documentation, please install the dependencies requried for documentation:
54+
If you need to update the documentation, please install the documentation dependencies:
5555

56-
```
56+
```bash
57+
# Recommended: install via the docs dependency group
58+
poetry install --with docs
59+
60+
# Alternative: install directly
5761
pip install -r docs/requirements_docs.txt
5862
```
5963

@@ -64,20 +68,67 @@ pip install -r docs/requirements_docs.txt
6468
1. Create a new branch from `main` for your contributions. Please use descriptive and concise branch names.
6569
2. Make your desired changes or additions to the codebase.
6670
3. Ensure that your code adheres to [PEP8](https://peps.python.org/pep-0008/) coding style guidelines.
67-
4. Write appropriate tests for your changes, ensuring that they pass.
68-
- `make test`
71+
4. Write appropriate tests for your changes and verify they pass:
72+
```bash
73+
just test
74+
```
6975
5. Update the documentation and examples, if necessary.
70-
6. Build the html documentation and verify if it works as expected. We have used Sphinx for documentation, you could build the documents as follows:
71-
- `cd docs`
72-
- `make clean`
73-
- `make html`
74-
7. Verify the html documents created under `docs/_build/html` directory. `index.html` file is the main file which contains link to all other files and doctree.
75-
76-
8. Commit your changes following the Conventional Commits specification (see below).
76+
6. Build the HTML documentation and verify it works as expected:
77+
```bash
78+
just docs
79+
```
80+
Verify the output under `docs/_build/html/`. `index.html` is the entry point.
81+
7. Run the full local check suite before pushing (lint, format, type-check, and all pre-commit hooks):
82+
```bash
83+
just check
84+
```
85+
8. Commit your changes following the Conventional Commits specification (see below):
86+
```bash
87+
just commit
88+
```
7789
9. Submit a pull request from your branch to `main` in the original repository.
7890
10. Wait for the maintainers to review your pull request. Address any feedback or comments if required.
7991
11. Once approved, your changes will be merged into the main codebase.
8092

93+
## Pre-commit Hooks
94+
95+
This project uses [pre-commit](https://pre-commit.com/) to enforce code quality automatically. The hooks run on two stages:
96+
97+
- **commit**`ruff` format and lint checks, plus general file hygiene hooks
98+
- **push**`pyright` type checking (slow, so deferred to push)
99+
100+
`just install` registers all three hook types (`commit-msg`, `pre-commit`, `pre-push`) so everything fires at the right time automatically.
101+
102+
> **Important:** Run `just check` before opening a PR. It executes all hooks against every file in the repo (both commit and push stages), giving you the same signal CI will see.
103+
104+
```bash
105+
# Run commit-stage hooks on all files (ruff format, ruff lint, file hygiene)
106+
just lint
107+
108+
# Run ruff formatter
109+
just format
110+
111+
# Run pyright type checker
112+
just typecheck
113+
114+
# Run ALL hooks across ALL files (commit + push stages) — equivalent to what CI checks
115+
just check
116+
```
117+
118+
If pre-commit reports files that _would be reformatted_, run `just format`, stage the changes, and commit before pushing. Formatting-only changes should be committed separately with `style: apply ruff formatting`.
119+
120+
### Type checking (pyright)
121+
122+
Type checking with `pyright` runs automatically on `git push` via the pre-push hook (registered by `just install`). It also runs in CI as the `typecheck` job in `.github/workflows/ci.yml`.
123+
124+
To run it manually at any time:
125+
126+
```bash
127+
just typecheck
128+
```
129+
130+
Fix any reported errors before opening a PR.
131+
81132
## Docs Workflow
82133

83134
Documentation is built with [Sphinx](https://www.sphinx-doc.org/) and hosted on [Read the Docs](https://readthedocs.org/).
@@ -124,8 +175,8 @@ brew install pandoc
124175
# or on Ubuntu
125176
sudo apt-get install pandoc
126177

127-
# Install doc dependencies
128-
pip install -r docs/requirements_docs.txt
178+
# Install doc dependencies (if not already done)
179+
poetry install --with docs
129180

130181
# Build HTML docs (warnings treated as errors)
131182
sphinx-build -b html docs/ docs/_build/html -W --keep-going

justfile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# list recipes
2-
defaut:
2+
default:
33
@just --list --unsorted
44

5-
# install dependencies
5+
# install dependencies and set up all pre-commit hooks
66
install:
77
poetry install
8-
poetry run pre-commit install --hook-type commit-msg --hook-type pre-commit
8+
poetry run pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push
99

10-
# update dependencies
10+
# update dependencies and pre-commit hook revisions
1111
update:
1212
poetry update
1313
poetry run pre-commit autoupdate
1414

15-
# update the poetry.lock file if the pyproject.toml file has been updated
15+
# regenerate poetry.lock without upgrading dependencies
1616
lock:
17-
poetry lock
17+
poetry lock --no-update
1818

1919
# remove Python file artifacts
2020
clean:
@@ -23,16 +23,32 @@ clean:
2323
find . -name '*~' -exec rm -f {} +
2424
find . -name '__pycache__' -exec rm -fr {} +
2525

26-
27-
# run ruff linting and fix all fixable linting errors
26+
# run ruff linting and fix all fixable errors
2827
lint:
2928
poetry run ruff check --fix .
3029

31-
# run ruff formatter to format all files
30+
# run docformatter and ruff formatter
3231
format:
3332
poetry run docformatter --in-place --recursive --wrap-summaries 120 --wrap-descriptions 120 .
3433
poetry run ruff format .
3534

35+
# run pyright type checking
36+
typecheck:
37+
poetry run pyright
38+
39+
# run tests with coverage
40+
test:
41+
poetry run pytest --cov=deeptab tests/
42+
43+
# build HTML docs locally (warnings treated as errors)
44+
docs:
45+
sphinx-build -b html docs/ docs/_build/html -W --keep-going
46+
47+
# run all pre-commit hooks on all files (commit + push stage)
48+
check:
49+
poetry run pre-commit run --all-files
50+
poetry run pre-commit run --all-files --hook-stage push
51+
3652
# create a conventional commit using commitizen
3753
commit:
3854
poetry run cz commit

0 commit comments

Comments
 (0)