Skip to content

Commit aa075d9

Browse files
authored
Add contribution, release & style guide (#103)
* Draft a guide for the release process * Update project URLs in pyproject.toml * Draft contribution guide * Complete release guide * Tweak contribution guide * Add design & style guide * Overwrite org CONTRIBUTION guide See https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors * Tweak contribution and installation guides
1 parent f28bed9 commit aa075d9

8 files changed

Lines changed: 180 additions & 3 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
You can find docstub's [contribution guide in our HTML docs](https://docstub.readthedocs.io/latest/development/contributing.html).
2+
3+
Or find its source in this repository at [docs/development/contributing.md](/docs/development/contributing.md)

docs/development/contributing.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Contributing
2+
3+
Thanks for trying out docstub and being interested in contributing!
4+
We'd greatly appreciate feedback and bug reports, as well as pointers to where the documentation is confusing and unclear.
5+
6+
Our project follows [Scientific Python's Code of Conduct](https://scientific-python.org/code_of_conduct/).
7+
8+
9+
## Reaching out
10+
11+
For bug reports, feature requests and feedback, head over to [docstub's issue tracker](https://github.com/scientific-python/docstub/issues) and feel very welcome to open an issue! 🚀
12+
13+
Before creating a feature request it might be useful to reference our [design guide](design.md), specifically our [goals](design.md#goals).
14+
15+
16+
## Development workflow
17+
18+
This section assumes familiarity with Python development.
19+
For a more general introduction you can check out [Scientific Python's Intro to development](https://learn.scientific-python.org/development/tutorials/dev-environment/).
20+
21+
22+
### Setup a development environment
23+
24+
Create a [fork of docstub](https://github.com/scientific-python/docstub/fork) and clone your fork.
25+
The following sections assume that you are running a shell inside that cloned project folder (`docstub/`).
26+
27+
```shell
28+
pip install --group dev --editable .
29+
pre-commit install
30+
```
31+
32+
33+
### Run tests
34+
35+
Run test suite and doctests:
36+
37+
```shell
38+
python -m pytest
39+
```
40+
41+
Check stub files for docstub:
42+
43+
```shell
44+
python -m mypy.stubtest \
45+
--mypy-config-file "pyproject.toml" \
46+
--allowlist "stubtest_allow.txt" \
47+
docstub
48+
```
49+
50+
Type check test suite:
51+
52+
```shell
53+
python -m mypy "tests/"
54+
python -m basedpyright "tests/"
55+
```
56+
57+
Before committing you can also perform all linting checks explicitly with
58+
59+
```shell
60+
pre-commit run --all
61+
```
62+
63+
64+
### Build the documentation
65+
66+
```shell
67+
python -m sphinx --fresh-env --nitpicky --fail-on-warning "docs/" "docs/build/"
68+
```

docs/development/design.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Design and style guide
2+
3+
## Goals
4+
5+
- Docstub facilitates gradual and easy adoption.
6+
- Docstub aims for readable type descriptions in docstrings.
7+
Extended doctype syntax should improve readability and work with existing conventions.
8+
- Docstub encourages fallback mechanisms like inline annotations, or creating a stub file manually.
9+
This helps with cases that would have a poor readability in docstrings, would be very complex, or are not supported.
10+
- Docstub is not a type checker.
11+
- Docstub is not a linter.
12+
13+
The development is, in part, motivated by an effort to add type annotations to the [scikit-image project](https://scikit-image.org).
14+
This may inform some short-term priorities and the roadmap.
15+
16+
That said, docstub is a project for the community and welcomes ideas, feedback, and contributions in any form!

docs/development/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Development
2+
3+
Resources for and about the development of docstub.
4+
5+
:::{toctree}
6+
:maxdepth: 1
7+
8+
contributing
9+
design
10+
release
11+
:::

docs/development/release.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Release process
2+
3+
This section documents the steps to make a release of docstub.
4+
Depending on the release type not all steps may be mandatory – use appropriate judgement.
5+
6+
7+
## Create release notes
8+
9+
Generate a [read-only GitHub token](https://github.com/settings/personal-access-tokens), install [changelist](https://github.com/scientific-python/changelist), and generate a first draft of the release notes with it.
10+
11+
```shell
12+
pip install changelist
13+
14+
RELEASE_TAG=...
15+
PREV_TAG=...
16+
export GH_TOKEN=...
17+
18+
changelist scientific-python/docstub \
19+
--version "${RELEASE_TAG}" \
20+
--out "doc/release_notes/v${RELEASE_TAG}.md" \
21+
"${PREV_TAG}" main
22+
```
23+
24+
- `RELEASE_TAG` is the tag of the current release (for example `v1.1.0`)
25+
- `PREV_TAG` is the tag of the previous release (for example `v1.0.0`).
26+
27+
So changelist will generate notes based on the changes between `${PREV_TAG}..main`.
28+
29+
Review and update `doc/release_notes/v${RELEASE_TAG}.md`.
30+
Don't forget to add the new document to `doc/release_notes/index.md`.
31+
32+
Create a pull request with the new release notes.
33+
If desired, include this pull request in the release notes, too.
34+
35+
36+
## Create a new tag
37+
38+
Once the pull request with the release notes is merged, tag the resulting commit with the desired version tag.
39+
This should be a signed tag.
40+
41+
```shell
42+
git tag --sign "v${RELEASE_TAG}"
43+
```
44+
45+
Include the release notes in the tag's message in the same formatting style as other release tags.
46+
47+
Review and then push the tag:
48+
49+
```shell
50+
git push origin "v${RELEASE_TAG}"
51+
```
52+
53+
54+
## Create a new "version" on Read the Docs
55+
56+
Login to https://app.readthedocs.org/projects/docstub.
57+
58+
Create a [new version](https://app.readthedocs.org/dashboard/docstub/version/create/) for the tag corresponding to the new release.
59+
60+
61+
## Trigger release workflow on GitHub
62+
63+
Trigger [docstub's release workflow on GitHub](https://github.com/scientific-python/docstub/actions/workflows/cd.yml).
64+
As a security measure, this workflow needs to be approved by one eligible maintainer.
65+
If successful, the workflow will build the package and push it to PyPI.
66+
67+
68+
## Format and publish GitHub release
69+
70+
[Create a new release draft](https://github.com/scientific-python/docstub/releases/new) and copy the content of `doc/release_notes/v${RELEASE_TAG}.md` into it.
71+
(Remove the duplicate level 1 headline in the first line.)
72+
73+
Review and publish.

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ It does so by supporting widely used readable conventions such as `array of dtyp
2222

2323
installation
2424
introduction
25+
development/index
2526
:::
2627

2728
:::{toctree}

docs/installation.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ You can use an isolated environment for docstub.
1212
So things like `pipx run docstub` or `uv tool run docstub` will work, too.
1313

1414

15-
## Development version
16-
15+
## Unreleased version
1716
In case you want to check out an unreleased version you can install the latest version directly from the repository with:
1817

1918
```shell
2019
pip install 'docstub @ git+https://github.com/scientific-python/docstub'
2120
```
2221

2322
You can append `@COMMIT_SHA` to the repository URL above to intall a specific version other that the `main` branch.
23+
24+
:::{tip}
25+
If you are want to set up a development environment instead, checkout the [Contribution guide](development/contributing.md).
26+
:::
27+

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ dependencies = [
4242
]
4343

4444
[project.urls]
45-
Homepage = "https://github.com/lagru/docstub"
45+
Source = "https://github.com/lagru/docstub"
46+
Documentation = "https://docstub.readthedocs.io"
4647

4748
[project.scripts]
4849
docstub = "docstub.__main__:cli"

0 commit comments

Comments
 (0)