From 19de1a76fddba36d19da8199c7b7e28e403811ca Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 10 Aug 2024 00:07:31 +0200 Subject: [PATCH] add './miri doc' command --- .github/workflows/ci.yml | 2 +- miri-script/src/commands.rs | 9 +++++++++ miri-script/src/main.rs | 6 ++++++ miri-script/src/util.rs | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc4e484fa3..efdeaeffe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: - name: clippy (all features) run: ./miri clippy --all-features -- -D warnings - name: rustdoc - run: RUSTDOCFLAGS="-Dwarnings" ./miri cargo doc --document-private-items + run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items # These jobs doesn't actually test anything, but they're only used to tell # bors the build completed, as there is no practical way to detect when a diff --git a/miri-script/src/commands.rs b/miri-script/src/commands.rs index cceec66de9..6cd1beace1 100644 --- a/miri-script/src/commands.rs +++ b/miri-script/src/commands.rs @@ -155,6 +155,7 @@ impl Command { | Command::Test { .. } | Command::Run { .. } | Command::Fmt { .. } + | Command::Doc { .. } | Command::Clippy { .. } => Self::auto_actions()?, | Command::Toolchain { .. } | Command::Bench { .. } @@ -169,6 +170,7 @@ impl Command { Command::Test { bless, flags, target } => Self::test(bless, flags, target), Command::Run { dep, verbose, many_seeds, target, edition, flags } => Self::run(dep, verbose, many_seeds, target, edition, flags), + Command::Doc { flags } => Self::doc(flags), Command::Fmt { flags } => Self::fmt(flags), Command::Clippy { flags } => Self::clippy(flags), Command::Bench { target, benches } => Self::bench(target, benches), @@ -441,6 +443,13 @@ impl Command { Ok(()) } + fn doc(flags: Vec) -> Result<()> { + let e = MiriEnv::new()?; + e.doc(path!(e.miri_dir / "Cargo.toml"), &flags)?; + e.doc(path!(e.miri_dir / "cargo-miri" / "Cargo.toml"), &flags)?; + Ok(()) + } + fn clippy(flags: Vec) -> Result<()> { let e = MiriEnv::new()?; e.clippy(path!(e.miri_dir / "Cargo.toml"), &flags)?; diff --git a/miri-script/src/main.rs b/miri-script/src/main.rs index 1e181cad08..9214823710 100644 --- a/miri-script/src/main.rs +++ b/miri-script/src/main.rs @@ -48,6 +48,11 @@ pub enum Command { /// Flags that are passed through to `miri`. flags: Vec, }, + /// Build documentation + Doc { + /// Flags that are passed through to `cargo doc`. + flags: Vec, + }, /// Format all sources and tests. Fmt { /// Flags that are passed through to `rustfmt`. @@ -148,6 +153,7 @@ fn main() -> Result<()> { let command = match args.next_raw().as_deref() { Some("build") => Command::Build { flags: args.remainder() }, Some("check") => Command::Check { flags: args.remainder() }, + Some("doc") => Command::Doc { flags: args.remainder() }, Some("test") => { let mut target = None; let mut bless = false; diff --git a/miri-script/src/util.rs b/miri-script/src/util.rs index 0f25b4c33d..32743b1a0a 100644 --- a/miri-script/src/util.rs +++ b/miri-script/src/util.rs @@ -152,6 +152,11 @@ impl MiriEnv { Ok(()) } + pub fn doc(&self, manifest_path: impl AsRef, args: &[String]) -> Result<()> { + self.cargo_cmd(manifest_path, "doc").args(args).run()?; + Ok(()) + } + pub fn clippy(&self, manifest_path: impl AsRef, args: &[String]) -> Result<()> { self.cargo_cmd(manifest_path, "clippy").arg("--all-targets").args(args).run()?; Ok(())