Skip to content

Commit 86e8831

Browse files
Merge pull request #1257 from ferdnyc/patch-1
docs: Fix list & code block formatting on RtD
2 parents beaeead + 4e7e8ac commit 86e8831

4 files changed

Lines changed: 57 additions & 20 deletions

File tree

docs/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
231231
3. Works for `include_package_data = True` in package building
232232

233233
**Entry point registration:**
234+
234235
```toml
235236
[project.entry-points."setuptools.file_finders"]
236237
setuptools_scm = "setuptools_scm._file_finders:find_files"
237238
```
238239

239240
**Files included by default:**
241+
240242
- All files tracked by Git (`git ls-files`)
241243
- All files tracked by Mercurial (`hg files`)
242244
- Includes: source code, documentation, tests, config files, etc.
@@ -290,6 +292,7 @@ tar -tzf dist/package-*.tar.gz
290292

291293

292294
### the configuration class
295+
293296
::: setuptools_scm.Configuration
294297
options:
295298
heading_level: 4

docs/extending.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545

4646
### `setuptools_scm.version_scheme`
47+
4748
Configures how the version number is constructed given a
4849
[ScmVersion][setuptools_scm.version.ScmVersion] instance and should return a string
4950
representing the version.
@@ -58,6 +59,7 @@ representing the version.
5859
and custom `.devN` versions will trigger an error.
5960

6061
**Examples:**
62+
6163
- Tag `v1.0.0` → version `1.0.1.dev0` (if dirty or distance > 0)
6264
- Tag `v1.0.0` → version `1.0.0` (if exact match)
6365

@@ -69,6 +71,7 @@ representing the version.
6971
for release branches.
7072

7173
**Examples:**
74+
7275
- Tag `v23.01.15.0` on same day → version `23.01.15.1.devN`
7376
- Tag `v23.01.15.0` on different day (e.g., 2023-01-16) → version `23.01.16.0.devN`
7477
- Tag `v2023.01.15.0` → uses 4-digit year format for new versions
@@ -78,6 +81,7 @@ representing the version.
7881
This is the recommended replacement for the deprecated `post-release` scheme.
7982

8083
**Examples:**
84+
8185
- Tag `v1.0.0` → version `1.0.0.post1.devN` (if distance > 0)
8286
- Tag `v1.0.0` → version `1.0.0` (if exact match)
8387

@@ -87,6 +91,7 @@ representing the version.
8791
!!! warning "This means version is no longer pseudo unique per commit"
8892

8993
**Examples:**
94+
9095
- Tag `v1.0.0` → version `1.0.0` (always, regardless of distance or dirty state)
9196

9297
`post-release (deprecated)`
@@ -97,6 +102,7 @@ representing the version.
97102
!!! warning "the recommended replacement is `no-guess-dev`"
98103

99104
**Examples:**
105+
100106
- Tag `1.0.0` → version `1.0.0.postN` (where N is the distance)
101107

102108
`python-simplified-semver`
@@ -109,6 +115,7 @@ representing the version.
109115
This scheme is not compatible with pre-releases.
110116

111117
**Examples:**
118+
112119
- Tag `1.0.0` on non-feature branch → version `1.0.1.devN`
113120
- Tag `1.0.0` on feature branch → version `1.1.0.devN`
114121

@@ -123,12 +130,15 @@ representing the version.
123130
Namespaces are unix pathname separated parts of a branch/tag name.
124131

125132
**Examples:**
133+
126134
- Tag `1.0.0` on release branch `release-1.0` → version `1.0.1.devN`
127135

128136
- Tag `1.0.0` on release branch `release/v1.0` → version `1.0.1.devN`
137+
129138
- Tag `1.0.0` on development branch → version `1.1.0.devN`
130139

131140
### `setuptools_scm.local_scheme`
141+
132142
Configures how the local part of a version is rendered given a
133143
[ScmVersion][setuptools_scm.version.ScmVersion] instance and should return a string
134144
representing the local version.

docs/integrations.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ setuptools-scm provides the `no-local-version` local scheme and environment vari
6060
#### The Problem
6161

6262
By default, setuptools-scm generates version numbers like:
63+
6364
- `1.2.3.dev4+g1a2b3c4d5` (development version with git hash)
6465
- `1.2.3+dirty` (dirty working directory)
6566

@@ -72,6 +73,7 @@ Use the `SETUPTOOLS_SCM_OVERRIDES_FOR_${DIST_NAME}` environment variable to over
7273
### GitHub Actions Example
7374

7475
Here's a complete GitHub Actions workflow that:
76+
7577
- Runs tests on all branches
7678
- Uploads development versions to test-PyPI from feature branches
7779
- Uploads development versions to PyPI from the main branch (with no-local-version)
@@ -290,9 +292,10 @@ publish-release:
290292
The environment variable `SETUPTOOLS_SCM_OVERRIDES_FOR_${DIST_NAME}` must be set where:
291293

292294
1. **`${DIST_NAME}`** is your package name normalized according to PEP 503:
293-
- Convert to uppercase
294-
- Replace hyphens and dots with underscores
295-
- Examples: `my-package` → `MY_PACKAGE`, `my.package` → `MY_PACKAGE`
295+
296+
- Convert to uppercase
297+
- Replace hyphens and dots with underscores
298+
- Examples: `my-package` → `MY_PACKAGE`, `my.package` → `MY_PACKAGE`
296299

297300
2. **Value** must be a valid TOML inline table format:
298301
```bash
@@ -316,10 +319,12 @@ However, the environment variable approach is preferred for CI/CD as it allows d
316319
#### Version Examples
317320

318321
**Development versions from main branch** (with `local_scheme = "no-local-version"`):
322+
319323
- Development commit: `1.2.3.dev4+g1a2b3c4d5` → `1.2.3.dev4` ✅ (uploadable to PyPI)
320324
- Dirty working directory: `1.2.3+dirty` → `1.2.3` ✅ (uploadable to PyPI)
321325

322326
**Tagged releases** (without overrides, using default local scheme):
327+
323328
- Tagged commit: `1.2.3` → `1.2.3` ✅ (uploadable to PyPI)
324329
- Tagged release on dirty workdir: `1.2.3+dirty` → `1.2.3+dirty` ❌ (should not happen in CI)
325330

docs/usage.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ dynamic = ["version"]
2626
```
2727

2828
This streamlined approach automatically enables version inference when:
29+
2930
- `setuptools-scm[simple]` is listed in `build-system.requires`
3031
- `version` is included in `project.dynamic`
3132

3233
!!! tip "When to use simplified activation"
3334

3435
Use simplified activation when you:
36+
3537
- Want basic SCM version inference with default settings
3638
- Don't need custom version schemes or file writing
3739
- Prefer minimal configuration
@@ -90,6 +92,7 @@ Version files can be created with the ``version_file`` directive.
9092
[tool.setuptools_scm]
9193
version_file = "pkg/_version.py"
9294
```
95+
9396
Where ``pkg`` is the name of your package.
9497

9598
Unless the small overhead of introspecting the version at runtime via
@@ -253,6 +256,7 @@ without copying the entire `.git` folder into the container image.
253256
RUN --mount=source=.git,target=.git,type=bind \
254257
pip install --no-cache-dir -e .
255258
```
259+
256260
However, this build step introduces a dependency to the state of your local
257261
`.git` folder the build cache and triggers the long-running pip install process on every build.
258262
To optimize build caching, one can use an environment variable to pretend a pseudo
@@ -332,6 +336,7 @@ setuptools-scm's default tag regex supports:
332336
- **Build metadata**: Anything after `+` is ignored
333337

334338
**Examples of valid tags:**
339+
335340
```bash
336341
# Recommended formats (with v prefix)
337342
v1.0.0
@@ -390,6 +395,7 @@ The prefixes are automatically added by setuptools-scm and should be included wh
390395
specifying node IDs in environment variables like `SETUPTOOLS_SCM_PRETEND_METADATA`.
391396

392397
**Examples:**
398+
393399
```bash
394400
# Git node ID
395401
1.0.0.dev5+g1a2b3c4d5
@@ -448,14 +454,16 @@ $ python -m setuptools_scm create-archival-file --full
448454
Alternatively, you can create the file manually:
449455

450456
**Stable version (recommended):**
451-
```{ .text file=".git_archival.txt"}
457+
458+
```{ .text title=".git_archival.txt"}
452459
node: $Format:%H$
453460
node-date: $Format:%cI$
454461
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
455462
```
456463

457464
**Full version (with branch information - can cause instability):**
458-
```{ .text file=".git_archival.txt"}
465+
466+
```{ .text title=".git_archival.txt"}
459467
# WARNING: Including ref-names can make archive checksums unstable
460468
# after commits are added post-release. Use only if describe-name is insufficient.
461469
node: $Format:%H$
@@ -475,11 +483,12 @@ tagging style.
475483
post-release. See [this issue][git-archive-issue] for more details.
476484

477485

478-
``` {.text file=".gitattributes"}
486+
``` {.text title=".gitattributes"}
479487
.git_archival.txt export-subst
480488
```
481489

482490
Finally, commit both files:
491+
483492
```commandline
484493
$ git add .git_archival.txt .gitattributes && git commit -m "add git archive support"
485494
```
@@ -488,7 +497,7 @@ $ git add .git_archival.txt .gitattributes && git commit -m "add git archive sup
488497

489498
If you see warnings like these when building your package:
490499

491-
```
500+
```text
492501
UserWarning: git archive did not support describe output
493502
UserWarning: unprocessed git archival found (no export subst applied)
494503
```
@@ -503,7 +512,7 @@ This typically happens when:
503512
**For development builds:**
504513
Exclude `.git_archival.txt` from your package to avoid warnings:
505514

506-
```{ .text file="MANIFEST.in"}
515+
```{ .text title="MANIFEST.in"}
507516
# Exclude archival file from development builds
508517
exclude .git_archival.txt
509518
```
@@ -526,14 +535,15 @@ Many CI systems and package repositories (like GitHub Actions) automatically han
526535
#### Integration with package managers
527536

528537
**MANIFEST.in exclusions:**
529-
```{ .text file="MANIFEST.in"}
538+
539+
```{ .text title="MANIFEST.in"}
530540
# Exclude development files from packages
531541
exclude .git_archival.txt
532542
exclude .gitattributes
533543
```
534544

535545

536-
```{ .text file=".gitattributes"}
546+
```{ .text title=".gitattributes"}
537547
# Archive configuration
538548
.git_archival.txt export-subst
539549
.gitignore export-ignore
@@ -542,14 +552,17 @@ exclude .gitattributes
542552
#### Troubleshooting
543553

544554
**Problem: "unprocessed git archival found" warnings**
555+
545556
-**Solution**: Add `exclude .git_archival.txt` to `MANIFEST.in` for development builds
546557
-**Alternative**: Build from actual git archives for releases
547558

548559
**Problem: "git archive did not support describe output" warnings**
560+
549561
- ℹ️ **Information**: This is expected when `.git_archival.txt` contains unexpanded templates
550562
-**Solution**: Same as above - exclude file or build from git archives
551563

552564
**Problem: Version detection fails in git archives**
565+
553566
-**Check**: Is `.gitattributes` configured with `export-subst`?
554567
-**Check**: Are you building from a properly created git archive?
555568
-**Check**: Does your git hosting provider support archive template expansion?
@@ -561,7 +574,8 @@ exclude .gitattributes
561574
!!! note "Version Files"
562575

563576
If you are creating a `_version.py` file, it should not be kept in version control. Add it to `.gitignore`:
564-
```
577+
578+
```{.ini title=".gitignore"}
565579
# Generated version file
566580
src/mypackage/_version.py
567581
```
@@ -594,31 +608,36 @@ would be required when not using `setuptools-scm`.
594608
**To exclude unwanted files:**
595609

596610
1. **Use `MANIFEST.in`** to exclude specific files/patterns:
597-
```
598-
exclude development.txt
599-
recursive-exclude tests *.pyc
600-
```
611+
612+
```{.text title="MANIFEST.in"}
613+
exclude development.txt
614+
recursive-exclude tests *.pyc
615+
```
601616
602617
2. **Configure Git archive** (for Git repositories):
603-
```bash
604-
# Add to .gitattributes
605-
tests/ export-ignore
606-
*.md export-ignore
607-
```
618+
619+
```{.bash title=".gitattributes"}
620+
# Add to .gitattributes
621+
tests/ export-ignore
622+
*.md export-ignore
623+
```
608624
609625
3. **Use `.hgignore`** or **Mercurial archive configuration** (for Mercurial repositories)
610626
611627
#### Troubleshooting
612628
613629
**Problem: Unwanted files in my package**
630+
614631
- ✅ **Solution**: Add exclusions to `MANIFEST.in`
615632
- ✅ **Alternative**: Use Git/Mercurial archive configuration
616633
617634
**Problem: Missing files in package**
635+
618636
- ✅ **Check**: Are the files tracked in your SCM?
619637
- ✅ **Solution**: `git add` missing files or override with `MANIFEST.in`
620638
621639
**Problem: File finder not working**
640+
622641
- ✅ **Check**: Is setuptools-scm installed in your build environment?
623642
- ✅ **Check**: Are you in a valid SCM repository?
624643

0 commit comments

Comments
 (0)