Skip to content

Commit

Permalink
add './miri doc' command
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 10, 2024
1 parent 6914420 commit 9e21767
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl Command {
| Command::Test { .. }
| Command::Run { .. }
| Command::Fmt { .. }
| Command::Doc { .. }
| Command::Clippy { .. } => Self::auto_actions()?,
| Command::Toolchain { .. }
| Command::Bench { .. }
Expand All @@ -182,6 +183,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),
Expand Down Expand Up @@ -454,6 +456,13 @@ impl Command {
Ok(())
}

fn doc(flags: Vec<String>) -> 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<String>) -> Result<()> {
let e = MiriEnv::new()?;
e.clippy(path!(e.miri_dir / "Cargo.toml"), &flags)?;
Expand Down
6 changes: 6 additions & 0 deletions miri-script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub enum Command {
/// Flags that are passed through to `miri`.
flags: Vec<String>,
},
/// Build documentation
Doc {
/// Flags that are passed through to `cargo doc`.
flags: Vec<String>,
},
/// Format all sources and tests.
Fmt {
/// Flags that are passed through to `rustfmt`.
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions miri-script/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ impl MiriEnv {
Ok(())
}

pub fn doc(&self, manifest_path: impl AsRef<OsStr>, args: &[String]) -> Result<()> {
self.cargo_cmd(manifest_path, "doc").args(args).run()?;
Ok(())
}

pub fn clippy(&self, manifest_path: impl AsRef<OsStr>, args: &[String]) -> Result<()> {
self.cargo_cmd(manifest_path, "clippy").arg("--all-targets").args(args).run()?;
Ok(())
Expand Down

0 comments on commit 9e21767

Please sign in to comment.