Skip to content

Commit 5dadf73

Browse files
committed
chore: derive the crate version in the docs and inherit the shared manifest fields
1 parent 8502bbd commit 5dadf73

27 files changed

Lines changed: 133 additions & 116 deletions

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Extract MSRV from Cargo.toml
4545
id: msrv
4646
run: |
47-
MSRV=$(scripts/sync-msrv.sh --print)
47+
MSRV=$(scripts/sync-docs.sh --print msrv)
4848
echo "version=$MSRV" >> "$GITHUB_OUTPUT"
4949
echo "MSRV: $MSRV"
5050
@@ -251,8 +251,8 @@ jobs:
251251
# Derive the MSRV in the documentation from Cargo.toml (single source of truth)
252252
# ════════════════════════════════════════════════════════════════════════════
253253

254-
sync-msrv:
255-
name: Sync MSRV
254+
sync-docs:
255+
name: Sync docs
256256
if: >-
257257
github.event_name != 'pull_request' ||
258258
(!startsWith(github.head_ref, 'release-plz-') && !startsWith(github.head_ref, 'dependabot/'))
@@ -267,7 +267,7 @@ jobs:
267267
run: git fetch origin main && git reset --hard origin/main
268268

269269
- name: Derive the MSRV in the documentation
270-
run: scripts/sync-msrv.sh
270+
run: scripts/sync-docs.sh
271271

272272
- name: Commit the documentation
273273
env:
@@ -286,10 +286,10 @@ jobs:
286286
git add -A
287287
288288
if [ "$EVENT" = "pull_request" ]; then
289-
git commit -m "chore: sync the MSRV in the documentation"
289+
git commit -m "chore: sync the documentation with the manifest"
290290
git push origin "HEAD:$HEAD_REF"
291291
else
292-
git commit -m "chore: sync the MSRV in the documentation [skip ci]"
292+
git commit -m "chore: sync the documentation with the manifest [skip ci]"
293293
git push origin HEAD:main
294294
fi
295295
@@ -496,13 +496,13 @@ jobs:
496496

497497
ci-success:
498498
name: CI Success
499-
needs: [check, fmt, docs, no-std, no-std-target, security, reuse, semver, sync-msrv, test]
499+
needs: [check, fmt, docs, no-std, no-std-target, security, reuse, semver, sync-docs, test]
500500
if: always()
501501
runs-on: ubuntu-latest
502502
steps:
503503
- name: Check all jobs
504504
run: |
505-
results="${{ needs.check.result }} ${{ needs.fmt.result }} ${{ needs.docs.result }} ${{ needs.no-std.result }} ${{ needs.no-std-target.result }} ${{ needs.security.result }} ${{ needs.reuse.result }} ${{ needs.semver.result }} ${{ needs.sync-msrv.result }} ${{ needs.test.result }}"
505+
results="${{ needs.check.result }} ${{ needs.fmt.result }} ${{ needs.docs.result }} ${{ needs.no-std.result }} ${{ needs.no-std-target.result }} ${{ needs.security.result }} ${{ needs.reuse.result }} ${{ needs.semver.result }} ${{ needs.sync-docs.result }} ${{ needs.test.result }}"
506506
507507
for r in $results; do
508508
if [[ "$r" != "success" ]]; then

‎ARCHITECTURE.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,25 +627,25 @@ CI tests on MSRV (1.99) and stable to prevent accidental newer Rust usage.
627627

628628
**Minimal setup** (library use):
629629
```toml
630-
masterror = { version = "0.24", default-features = false }
630+
masterror = { version = "0.31.1", default-features = false }
631631
```
632632

633633
**HTTP service**:
634634
```toml
635-
masterror = { version = "0.24", features = ["std", "axum", "tracing"] }
635+
masterror = { version = "0.31.1", features = ["std", "axum", "tracing"] }
636636
```
637637

638638
**Full-stack service**:
639639
```toml
640-
masterror = { version = "0.24", features = [
640+
masterror = { version = "0.31.1", features = [
641641
"std", "axum", "sqlx", "reqwest", "redis",
642642
"tracing", "metrics", "backtrace"
643643
] }
644644
```
645645

646646
**Rapid prototype**:
647647
```toml
648-
masterror = { version = "0.24", features = ["turnkey"] }
648+
masterror = { version = "0.31.1", features = ["turnkey"] }
649649
```
650650

651651
### Error Budget

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
name = "masterror"
77
version = "0.31.1"
88
rust-version.workspace = true
9-
edition = "2024"
10-
license = "MIT"
11-
repository = "https://github.com/RAprogramm/masterror"
9+
edition.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
1212
readme = "README.md"
1313
description = "Application error types and response mapping"
1414
documentation = "https://docs.rs/masterror"

‎Makefile.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ description = "Run checks and publish the crate (requires TAG and token)"
170170

171171
# ------- Extras -------
172172

173-
[tasks.sync-msrv]
173+
[tasks.sync-docs]
174174
category = "Documentation"
175175
clear = true
176-
description = "Derive the MSRV in the documentation from Cargo.toml"
176+
description = "Derive the documentation values from Cargo.toml"
177177
script_runner = "bash"
178-
script = ['scripts/sync-msrv.sh']
178+
script = ['scripts/sync-docs.sh']
179179

180180
[tasks.format]
181181
category = "Format"

‎README.ko.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ SPDX-License-Identifier: MIT
139139

140140
~~~toml
141141
[dependencies]
142-
masterror = { version = "0.28.0", default-features = false }
142+
masterror = { version = "0.31.1", default-features = false }
143143
# or with features:
144-
# masterror = { version = "0.28.0", features = [
144+
# masterror = { version = "0.31.1", features = [
145145
# "std", "axum", "actix", "openapi",
146146
# "serde_json", "tracing", "metrics", "backtrace",
147147
# "colored", "sqlx", "sqlx-migrate", "reqwest",
@@ -555,7 +555,7 @@ match mode {
555555

556556
~~~toml
557557
[dependencies]
558-
masterror = { version = "0.28.0", features = ["colored"] }
558+
masterror = { version = "0.31.1", features = ["colored"] }
559559
~~~
560560

561561
`colored` 기능 없이 오류는 `AppErrorKind` 레이블을 표시합니다:

‎README.ru.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ SPDX-License-Identifier: MIT
140140

141141
~~~toml
142142
[dependencies]
143-
masterror = { version = "0.28.0", default-features = false }
143+
masterror = { version = "0.31.1", default-features = false }
144144
# or with features:
145-
# masterror = { version = "0.28.0", features = [
145+
# masterror = { version = "0.31.1", features = [
146146
# "std", "axum", "actix", "openapi",
147147
# "serde_json", "tracing", "metrics", "backtrace",
148148
# "colored", "sqlx", "sqlx-migrate", "reqwest",
@@ -561,7 +561,7 @@ match mode {
561561

562562
~~~toml
563563
[dependencies]
564-
masterror = { version = "0.28.0", features = ["colored"] }
564+
masterror = { version = "0.31.1", features = ["colored"] }
565565
~~~
566566

567567
Без функции `colored` ошибки отображают метку `AppErrorKind`:

‎masterror-derive/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
name = "masterror-derive"
77
rust-version.workspace = true
88
version = "0.13.1"
9-
edition = "2024"
10-
license = "MIT"
11-
repository = "https://github.com/RAprogramm/masterror"
9+
edition.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
1212
readme = "README.md"
1313
description = "Derive macros for masterror"
1414

‎masterror-derive/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Procedural macros that power [`masterror`](https://crates.io/crates/masterror)'s
2222

2323
```toml
2424
[dependencies]
25-
masterror = "0.10"
25+
masterror = "0.31.1"
2626
```
2727

2828
```rust

‎masterror-template/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
name = "masterror-template"
77
version = "0.5.1"
88
rust-version.workspace = true
9-
edition = "2024"
10-
repository = "https://github.com/RAprogramm/masterror"
9+
edition.workspace = true
10+
repository.workspace = true
1111
readme = "README.md"
1212
description = "Template utilities for masterror and its derive macros"
13-
license = "MIT"
13+
license.workspace = true
1414

1515
[dependencies]

‎scripts/sync-docs.sh‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
# Derive the MSRV and the crate version in the documentation from Cargo.toml,
3+
# the single source of truth.
4+
#
5+
# Usage:
6+
# scripts/sync-docs.sh rewrite the documentation
7+
# scripts/sync-docs.sh --print msrv
8+
# scripts/sync-docs.sh --print version
9+
10+
set -euo pipefail
11+
12+
root="$(git rev-parse --show-toplevel)"
13+
cd "$root"
14+
15+
read_manifest_value() {
16+
awk -v section_name="$1" -v key="$2" '
17+
$0 == "[" section_name "]" { section = 1; next }
18+
/^\[/ { section = 0 }
19+
section && $1 == key { gsub(/["[:space:]]/, "", $3); print $3; exit }
20+
' Cargo.toml
21+
}
22+
23+
msrv="$(read_manifest_value workspace.package rust-version)"
24+
version="$(read_manifest_value package version)"
25+
26+
for value in "$msrv" "$version"; do
27+
if ! printf '%s' "$value" | grep -Eq '^[0-9]+(\.[0-9]+){0,2}$'; then
28+
echo "the value read from Cargo.toml is not a version: $value" >&2
29+
exit 1
30+
fi
31+
done
32+
33+
if [ "${1:-}" = "--print" ]; then
34+
case "${2:-}" in
35+
msrv) printf '%s\n' "$msrv" ;;
36+
version) printf '%s\n' "$version" ;;
37+
*)
38+
echo "usage: scripts/sync-docs.sh --print [msrv|version]" >&2
39+
exit 1
40+
;;
41+
esac
42+
exit 0
43+
fi
44+
45+
git -c core.quotePath=false ls-files '*.md' \
46+
| grep -v -e '^README\.md$' -e '^README\.template\.md$' -e '^SECURITY\.md$' \
47+
| while IFS= read -r document; do
48+
sed -i -E \
49+
-e "s/(MSRV[^0-9]{0,24})[0-9]+\.[0-9]+/\1${msrv}/g" \
50+
-e "s/(rust-version = \")[0-9]+\.[0-9]+(\")/\1${msrv}\2/g" \
51+
-e "s/(targets Rust )[0-9]+\.[0-9]+/\1${msrv}/g" \
52+
-e "s/(masterror = \{ version = \")[0-9]+\.[0-9]+(\.[0-9]+)?(\")/\1${version}\3/g" \
53+
-e "s/(masterror = \")[0-9]+\.[0-9]+(\.[0-9]+)?(\")/\1${version}\3/g" \
54+
"$document"
55+
done
56+
57+
git diff --stat

0 commit comments

Comments
 (0)