Skip to content

Commit 391b744

Browse files
authored
Fix docs on migrating to the template (#476)
* Cleaner heading hierarchy * Fix #475 * Fix intro paragraph x-refs
1 parent cbf6b45 commit 391b744

1 file changed

Lines changed: 25 additions & 31 deletions

File tree

{{cookiecutter.project_name}}/docs/template_usage.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Using this template
22

3-
Welcome to the developer guidelines! This document is split into two parts:
3+
Welcome to the developer guidelines!
4+
This section is relevant primarily for the repository maintainer
5+
and shows how to connect continuous integration services and documents initial set-up of the repository.
6+
For information relevant to all developers who want to make a contribution,
7+
please refer to the [contributor guide](contributing.md#contributing-guide).
48

5-
1. The [repository setup](#setting-up-the-repository).
6-
This section is relevant primarily for the repository maintainer and shows how to connect continuous integration services and documents initial set-up of the repository.
7-
2. The [contributor guide](contributing.md#contributing-guide).
8-
It contains information relevant to all developers who want to make a contribution.
9-
10-
## Setting up the repository
11-
12-
### First commit
9+
## First commit
1310

1411
If you are reading this, you should have just completed the repository creation with:
1512

@@ -47,22 +44,22 @@ While the repository at this point can be directly used, there are few remaining
4744

4845
[github quickstart guide]: https://docs.github.com/en/get-started/quickstart/create-a-repo?tool=webui
4946

50-
### The pyproject.toml file
47+
## The pyproject.toml file
5148

5249
Modern Python package management uses a `pyproject.toml` that was first introduced in [PEP 518](https://peps.python.org/pep-0518/).
5350
This file contains build system requirements and information, which are used by pip to build the package, and tool configurations.
5451
For more details please have a look at [pip's description of the pyproject.toml file](https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/).
5552
It also serves as a single point of truth to define test environments and how docs are built by leveraging
5653
the [hatch][] project manager, but more about that in the [contributing guide](contributing.md).
5754

58-
#### Important metadata fields
55+
### Important metadata fields
5956

6057
The `[project]` section in the `pyproject.toml` file defines several important metadata fields that might require editing.
6158
For example, the `name`, `description`, `authors` fields could need updates as the project evolves.
6259
Especially, the `version` field needs to be adapted if newer versions of the package are to be released.
6360
See {ref}`vcs-based-versioning` for more details.
6461

65-
#### Dependency management
62+
### Dependency management
6663

6764
Package dependencies can be added to the `dependencies` of the `[project]` section.
6865
You can constrain versions using any of `>=`, `>`, `<`, `<=`, `==`, `!=`, and `~=`.
@@ -72,7 +69,7 @@ As another example, if there is a known buggy version, you could exclude it like
7269
Further optional dependencies are defined in the `[project.optional-dependencies]` section such as dependencies only for tests (`test`).
7370
All dependencies listed in such optional dependency groups can then be installed by specifying them like: `pip install <package-name>[test]`.
7471

75-
#### Tool configurations
72+
### Tool configurations
7673

7774
The `pyproject.toml` file also serves as single configuration file for many tools such as many {ref}`pre-commit`.
7875
For example, the line length for auto-formatting can be configured as follows:
@@ -84,7 +81,7 @@ line-length = 120
8481

8582
[hatch]: https://hatch.pypa.io/latest/
8683

87-
### Coverage tests with _Codecov_
84+
## Coverage tests with _Codecov_
8885

8986
Coverage tells what fraction of the code is "covered" by unit tests,
9087
thereby encouraging contributors to [write tests](contributing.md#writing-tests).
@@ -102,7 +99,7 @@ To set it up, simply go to the [codecov app][] page and follow the instructions
10299
[codecov docs]: https://docs.codecov.com/docs
103100
[OpenID connect]: https://docs.github.com/en/actions/concepts/security/openid-connect
104101

105-
### Documentation on _readthedocs_
102+
## Documentation on _readthedocs_
106103

107104
We recommend using [readthedocs.org][] (RTD) to build and host the documentation for your project.
108105
To enable readthedocs, head over to [their website][readthedocs.org] and sign in with your GitHub account.
@@ -123,7 +120,7 @@ See a guide [here](https://docs.readthedocs.io/en/stable/guides/importing-privat
123120

124121
(github-actions)=
125122

126-
### Github Actions
123+
## Github Actions
127124

128125
[GitHub Actions][] is a continuous integration (CI)/continuous development (CD) automation tool that enables workflows for building, testing, and deploying code directly from a GitHub repository.
129126
It uses YAML-based configuration files to define jobs and steps, which can be triggered by events like pushes, pull requests, or scheduled runs.
@@ -148,7 +145,7 @@ There you can see the execution history, logs, and (re-)trigger workflows manual
148145
(automating-pypi-released-using-github-actions)=
149146
(configuring-the-github-workflow)=
150147

151-
### Automating the PyPI release using GitHub actions
148+
## Automating the PyPI release using GitHub actions
152149

153150
Tags adhering to `"*.*.*"` that are pushed to the `main` branch will trigger the release Github workflow that automatically builds and uploads the Python package to [PyPI][].
154151

@@ -170,15 +167,15 @@ For more details, please refer to the official [PyPI guide for setting up truste
170167

171168
(pre-commit)=
172169

173-
### Pre-commit checks
170+
## Pre-commit checks
174171

175172
[Pre-commit][] checks are fast programs that check code for errors, inconsistencies and code styles, before the code is committed.
176173

177174
This template uses a number of pre-commit checks.
178175
In this section we'll detail what is used, where they're defined, and how to modify these checks.
179176

180177

181-
#### Pre-commit CI
178+
### Pre-commit CI
182179

183180
We recommend setting up [pre-commit.ci][] to enforce consistency checks on every commit and pull-request.
184181

@@ -189,7 +186,7 @@ You may choose to enable the service for an entire organization or on a per-repo
189186
Once authorized, pre-commit.ci should automatically be activated.
190187

191188

192-
#### Overview of pre-commit hooks used by the template
189+
### Overview of pre-commit hooks used by the template
193190

194191
The following pre-commit hooks are for code style and format:
195192

@@ -230,19 +227,19 @@ The following pre-commit hooks are for errors and inconsistencies:
230227
- [Ruff-specific rules](https://beta.ruff.rs/docs/rules/#ruff-specific-rules-ruf) (rule category: `RUF`):
231228
- `RUF100`: remove unnecessary `# noqa` comments ()
232229

233-
#### How to add or remove pre-commit checks
230+
### How to add or remove pre-commit checks
234231

235232
The [pre-commit checks](#pre-commit-checks) check for both correctness and stylistic errors.
236233
In some cases it might overshoot and you may have good reasons to ignore certain warnings.
237234
This section shows you where these checks are defined, and how to enable/ disable them.
238235

239-
##### pre-commit
236+
#### pre-commit
240237

241238
You can add or remove pre-commit checks by simply deleting relevant lines in the `.pre-commit-config.yaml` file under the repository root.
242239
Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for [ruff][]) or tool-specific config files,
243240
such as `biome.jsonc` for [biome][].
244241

245-
##### Ruff
242+
#### Ruff
246243

247244
This template configures `ruff` through the `[tool.ruff]` entry in the `pyproject.toml`.
248245
For further information `ruff` configuration, see [the docs][ruff-config].
@@ -305,7 +302,7 @@ add it to Ruff’s [`external = [...]`][ruff-external] setting to prevent `RUF10
305302
[ruff-external]: https://docs.astral.sh/ruff/settings/#external
306303

307304

308-
### API design
305+
## API design
309306

310307
Scverse ecosystem packages should operate on [AnnData][], [MuData][], and/or [SpatialData][] data structures and typically use an API
311308
as originally [introduced by scanpy][scanpy-api] with the following submodules:
@@ -325,7 +322,7 @@ there may also be good reasons to choose a different approach, e.g. using an obj
325322

326323
(vcs-based-versioning)=
327324

328-
### Using VCS-based versioning
325+
## Using VCS-based versioning
329326

330327
By default, the template uses hard-coded version numbers that are set in `pyproject.toml`.
331328
If you prefer to have your project automatically infer version numbers from git tags,
@@ -361,7 +358,7 @@ Don't forget to update the [Making a release section](contributing.md#publishing
361358

362359
[hatch-vcs]: https://pypi.org/project/hatch-vcs/
363360

364-
### Automated template sync
361+
## Automated template sync
365362

366363
Automated template sync is enabled by default for public repositories on GitHub.
367364
Our [scverse-bot][] automatically crawls GitHub for repositories that are based on this template,
@@ -384,9 +381,6 @@ The following hints may be useful to work with the template sync:
384381

385382
:::
386383

387-
388-
:::
389-
390384
[list of template repositories]: https://github.com/scverse/ecosystem-packages/blob/main/template-repos.yml
391385
[scverse-bot]: https://github.com/scverse-bot
392386

@@ -408,7 +402,7 @@ Here's one way how to do it:
408402

409403
```bash
410404
mkdir template && cd template
411-
cruft create https://github.com/scverse/cookiecutter-scverse
405+
uvx --with pre-commit cruft create https://github.com/scverse/cookiecutter-scverse
412406
```
413407

414408
4. remove everything from the existing repo
@@ -425,7 +419,7 @@ Here's one way how to do it:
425419

426420
```bash
427421
# move everything, including hidden folders, excluding `.git`.
428-
rsync -av --exclude='.git' ../template/$REPO ./
422+
rsync -av --exclude='.git' ../template/$REPO/ ./
429423
git add -A
430424
git commit -m "init from template"
431425
```

0 commit comments

Comments
 (0)