Diff of /docs/contributing.md [000000] .. [e5f1db]

Switch to unified view

a b/docs/contributing.md
1
# Contributing guide
2
3
Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this repo, too.
4
This document will not reproduce the entire content from there.
5
Instead, it aims at summarizing the most important information to get you started on contributing.
6
7
We assume that you are already familiar with git and with making pull requests on GitHub.
8
If not, please refer to the [scanpy developer guide][].
9
10
## Cloning the repository
11
12
ehrapy consists of this main repository and a git submodule [ehrapy-tutorials](https://github.com/theislab/ehrapy-tutorials) which hosts tutorial notebooks.
13
Clone both using:
14
15
```bash
16
git clone --recurse-submodules https://github.com/theislab/ehrapy
17
```
18
19
More details on the tutorials submodule are described in the [Writing documentation](#writing-documentation) section.
20
21
## Installing dev dependencies
22
23
In addition to the packages needed to _use_ this package, you need additional python packages to _run tests_ and _build
24
the documentation_. It's easy to install them using `pip`:
25
26
```bash
27
cd ehrapy
28
pip install -e ".[dev,test,docs]"
29
```
30
31
## Code-style
32
33
This project uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either
34
automatically fix issues with the code, or raise an error message.
35
36
To enable pre-commit locally, simply run
37
38
```bash
39
pre-commit install
40
```
41
42
in the root of the repository. Pre-commit will automatically download all dependencies when it is run for the first time.
43
44
Alternatively, you can rely on the [pre-commit.ci][] service enabled on GitHub. If you didn't run `pre-commit` before
45
pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
46
47
If pre-commit.ci added a commit on a branch you still have been working on locally, simply use
48
49
```bash
50
git pull --rebase
51
```
52
53
to integrate the changes into yours.
54
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.
55
56
Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [black][black-editors]
57
and [prettier][prettier-editors].
58
59
[black-editors]: https://black.readthedocs.io/en/stable/integrations/editors.html
60
[prettier-editors]: https://prettier.io/docs/en/editors.html
61
62
## Writing tests
63
64
```{note}
65
Remember to first install the package with `pip install -e ".[dev,test,docs]"`
66
```
67
68
This package uses the [pytest][] for automated testing. Please [write tests][scanpy-test-docs] for every function added
69
to the package.
70
71
Most IDEs integrate with pytest and provide a GUI to run tests. Alternatively, you can run all tests from the
72
command line by executing
73
74
```bash
75
pytest
76
```
77
78
in the root of the repository. Continuous integration will automatically run the tests on all pull requests.
79
80
[scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests
81
82
## Publishing a release
83
84
### Updating the version number
85
86
Before making a release, you need to update the version number. Please adhere to [Semantic Versioning][semver], in brief
87
88
> Given a version number MAJOR.MINOR.PATCH, increment the:
89
>
90
> 1.  MAJOR version when you make incompatible API changes,
91
> 2.  MINOR version when you add functionality in a backwards compatible manner, and
92
> 3.  PATCH version when you make backwards compatible bug fixes.
93
>
94
> Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
95
96
Once you are done, run
97
98
```
99
git push --tags
100
```
101
102
to publish the created tag on GitHub.
103
104
### Building and publishing the package on PyPI
105
106
Python packages are not distributed as source code, but as _distributions_. The most common distribution format is the so-called _wheel_. To build a _wheel_, run
107
108
```bash
109
python -m build
110
```
111
112
This command creates a _source archive_ and a _wheel_, which are required for publishing your package to [PyPI][]. These files are created directly in the root of the repository.
113
114
Before uploading them to [PyPI][] you can check that your _distribution_ is valid by running:
115
116
```bash
117
twine check dist/*
118
```
119
120
and finally publishing it with:
121
122
```bash
123
twine upload dist/*
124
```
125
126
Provide your username and password when requested and then go check out your package on [PyPI][]!
127
128
For more information, follow the [Python packaging tutorial][].
129
130
It is possible to automate this with GitHub actions, see also [this feature request][pypi-feature-request]
131
in the cookiecutter-scverse template.
132
133
[python packaging tutorial]: https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives
134
[pypi-feature-request]: https://github.com/scverse/cookiecutter-scverse/issues/88
135
136
## Writing documentation
137
138
Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features:
139
140
- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
141
- Google-style docstrings
142
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
143
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
144
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
145
146
See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information
147
on how to write documentation.
148
149
### Tutorials with myst-nb and jupyter notebooks
150
151
The documentation is set-up to render jupyter notebooks stored in the `docs/tutorials` directory using [myst-nb][].
152
Currently, only notebooks in `.ipynb` format are supported that will be included with both their input and output cells.
153
154
These notebooks come from [ehrapy-tutorials](https://github.com/theislab/ehrapy-tutorials) which is a git submodule of ehrapy.
155
156
#### Working with the git submodule
157
158
Whenever the tutorials are updated in the submodule, two pull requests need to be made.
159
Submit a pull request to [ehrapy-tutorials](https://github.com/theislab/ehrapy-tutorials) and ensure that the CI passes.
160
Further, submit a pull request on the ehrapy repository where the submodule also contains the commit and ensure that
161
the documentation as build by ReadTheDocs properly shows the updated notebooks.
162
Both pull requests need to be merged to ensure that no repository gets out of sync.
163
164
### Hints
165
166
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
167
  if you do so can sphinx automatically create a link to the external documentation.
168
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
169
  the `nitpick_ignore` list in `docs/conf.py`
170
171
### Building the docs locally
172
173
```bash
174
cd docs
175
make html
176
open _build/html/index.html
177
```
178
179
<!-- Links -->
180
181
[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html
182
[cookiecutter-scverse-instance]: https://cookiecutter-scverse-instance.readthedocs.io/en/latest/template_usage.html
183
[github quickstart guide]: https://docs.github.com/en/get-started/quickstart/create-a-repo?tool=webui
184
[codecov]: https://about.codecov.io/sign-up/
185
[codecov docs]: https://docs.codecov.com/docs
186
[codecov bot]: https://docs.codecov.com/docs/team-bot
187
[codecov app]: https://github.com/apps/codecov
188
[pre-commit.ci]: https://pre-commit.ci/
189
[readthedocs.org]: https://readthedocs.org/
190
[myst-nb]: https://myst-nb.readthedocs.io/en/latest/
191
[jupytext]: https://jupytext.readthedocs.io/en/latest/
192
[pre-commit]: https://pre-commit.com/
193
[anndata]: https://github.com/scverse/anndata
194
[mudata]: https://github.com/scverse/mudata
195
[pytest]: https://docs.pytest.org/
196
[semver]: https://semver.org/
197
[sphinx]: https://www.sphinx-doc.org/en/master/
198
[myst]: https://myst-parser.readthedocs.io/en/latest/intro.html
199
[numpydoc-napoleon]: https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html
200
[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html
201
[sphinx autodoc typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints
202
[pypi]: https://pypi.org/