Skip to content

Commit d44f2ee

Browse files
committed
Merge rust-bitcoin/rust-bitcoin-maintainer-tools#107: cargo-rbmt: clean docs and extend with --open arg
e35355f cargo-rbmt: beef up the api's implicit dep requirement docs (Nick Johnson) 91491fb cargo-rbmt: extend docs with the often use --open arg (Nick Johnson) 50667c9 cargo-rbmt: simplify justfile (Nick Johnson) Pull request description: ACKs for top commit: tcharding: ACK e35355f Tree-SHA512: 2ee85f42e4ea736195e9e62a5c0036353055cabd223b9b7b124d9f3e04285be67ab4031d9bfc6a798538d0e218a59d0b5f100aaa6a2590518422e8f20f165079
2 parents a9049f5 + e35355f commit d44f2ee

4 files changed

Lines changed: 46 additions & 25 deletions

File tree

cargo-rbmt/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ When you specify `--lock-file`, the tool copies that lock file to `Cargo.lock` b
151151

152152
## API
153153

154-
The `api` command helps maintain API stability by generating public API snapshots and checking for breaking changes. It uses the [public-api](https://github.com/Enselic/cargo-public-api) crate to analyze a crate's public interface. **Requires running with a nightly toolchain after nightly-2025-08-02** due to docsrs dependencies.
154+
The `api` command helps maintain API stability by generating public API snapshots and checking for breaking changes. It uses the [public-api](https://github.com/Enselic/cargo-public-api) crate to analyze a crate's public interface.
155+
156+
> **NOTE:** `api` has an implicit dependency on the version of the nightly toolchain since it relies on an unstable docsrs interface. Currently, it requires [*nightly-2025-08-02* or later](https://github.com/cargo-public-api/cargo-public-api/blob/main/README.md#compatibility-matrix).
155157
156158
```bash
157159
cargo rbmt api

cargo-rbmt/justfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
# This justfile is functional for cargo-rbmt, but also showcases a pattern for
2-
# how to integrate rbmt into a justfile.
3-
#
4-
# The generic `_rbmt` recipe handles lock file selection (existing, recent,
5-
# minimal) and installation of rbmt. Toolchain selection is handled internally
6-
# by rbmt.
7-
#
8-
# Specific recipes (`lint`, `test`) call the generic `_rbmt` recipe with
9-
# appropriate defaults.
1+
# This justfile is functional for cargo-rbmt, but also showcases
2+
# a pattern for how to integrate rbmt into a justfile.
103

114
# List available recipes.
125
_default:
136
@just --list
147

158
# Install rbmt from the local workspace path.
9+
[group('system')]
1610
@install:
1711
cargo install --quiet --path .
1812

1913
# Install workspace toolchains.
14+
[group('system')]
2015
@toolchains: install
16+
# Redirect exports since just recipes are a sub-shell.
2117
RBMT_LOG_LEVEL=quiet cargo rbmt toolchains > /dev/null
2218

23-
# Run CI tasks using rbmt.
24-
@_rbmt task lock="existing": install toolchains
25-
RBMT_LOG_LEVEL=quiet cargo rbmt --lock-file {{lock}} {{task}}
19+
# Setup rbmt and run with given args.
20+
@rbmt *args: toolchains
21+
RBMT_LOG_LEVEL=quiet cargo rbmt {{args}}
22+
23+
# Build and open docs.
24+
@docs: (rbmt "docsrs --open")
2625

2726
# Format files.
28-
@fmt: (_rbmt "fmt")
27+
@fmt: (rbmt "fmt")
2928

3029
# Lint with clippy.
31-
@lint: (_rbmt "lint")
30+
@lint: (rbmt "lint")
3231

3332
# Run tests.
34-
@test: (_rbmt "test")
33+
@test: (rbmt "test")
3534

3635
# Update Cargo-minimal.lock and Cargo-recent.lock files.
37-
@lock: (_rbmt "lock")
36+
@lock: (rbmt "lock")

cargo-rbmt/src/docs.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::toolchain::{prepare_toolchain, Toolchain};
1010
///
1111
/// This verifies that `cargo doc` works correctly for users with stable Rust.
1212
/// Uses basic rustdoc warnings to catch common documentation issues.
13-
pub fn run(sh: &Shell, packages: &[Package]) -> Result<(), Box<dyn std::error::Error>> {
13+
pub fn run(sh: &Shell, packages: &[Package], open: bool) -> Result<(), Box<dyn std::error::Error>> {
1414
prepare_toolchain(sh, Toolchain::Stable)?;
1515

1616
let mut cmd = quiet_cmd!(sh, "cargo --locked doc --all-features --no-deps");
@@ -20,6 +20,10 @@ pub fn run(sh: &Shell, packages: &[Package]) -> Result<(), Box<dyn std::error::E
2020
cmd = cmd.args(&["-p", &package.id]);
2121
}
2222

23+
if open {
24+
cmd = cmd.arg("--open");
25+
}
26+
2327
cmd.env("RUSTDOCFLAGS", "-D warnings").run()?;
2428

2529
Ok(())
@@ -29,7 +33,11 @@ pub fn run(sh: &Shell, packages: &[Package]) -> Result<(), Box<dyn std::error::E
2933
///
3034
/// This emulates the docs.rs build environment by using the nightly toolchain
3135
/// with `--cfg docsrs` enabled. This catches docs.rs-specific issues.
32-
pub fn run_docsrs(sh: &Shell, packages: &[Package]) -> Result<(), Box<dyn std::error::Error>> {
36+
pub fn run_docsrs(
37+
sh: &Shell,
38+
packages: &[Package],
39+
open: bool,
40+
) -> Result<(), Box<dyn std::error::Error>> {
3341
prepare_toolchain(sh, Toolchain::Nightly)?;
3442

3543
let mut cmd = quiet_cmd!(sh, "cargo --locked doc --all-features --no-deps");
@@ -39,6 +47,10 @@ pub fn run_docsrs(sh: &Shell, packages: &[Package]) -> Result<(), Box<dyn std::e
3947
cmd = cmd.args(&["-p", &package.id]);
4048
}
4149

50+
if open {
51+
cmd = cmd.arg("--open");
52+
}
53+
4254
cmd.env("RUSTDOCFLAGS", "--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links").run()?;
4355

4456
Ok(())

cargo-rbmt/src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,17 @@ enum Commands {
5454
/// Run the linter (clippy) for workspace and all crates.
5555
Lint,
5656
/// Build documentation with stable toolchain.
57-
Docs,
57+
Docs {
58+
/// Open documentation in browser after building.
59+
#[arg(long)]
60+
open: bool,
61+
},
5862
/// Build documentation with nightly toolchain for docs.rs.
59-
Docsrs,
63+
Docsrs {
64+
/// Open documentation in browser after building.
65+
#[arg(long)]
66+
open: bool,
67+
},
6068
/// Run benchmark tests for all crates.
6169
Bench,
6270
/// Run tests with specified toolchain.
@@ -164,13 +172,13 @@ fn main() {
164172
eprintln!("Error running lint task: {}", e);
165173
process::exit(1);
166174
},
167-
Commands::Docs =>
168-
if let Err(e) = docs::run(&sh, &packages) {
175+
Commands::Docs { open } =>
176+
if let Err(e) = docs::run(&sh, &packages, open) {
169177
eprintln!("Error building docs: {}", e);
170178
process::exit(1);
171179
},
172-
Commands::Docsrs =>
173-
if let Err(e) = docs::run_docsrs(&sh, &packages) {
180+
Commands::Docsrs { open } =>
181+
if let Err(e) = docs::run_docsrs(&sh, &packages, open) {
174182
eprintln!("Error building docs.rs docs: {}", e);
175183
process::exit(1);
176184
},

0 commit comments

Comments
 (0)