mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 06:54:33 +01:00
xtask: Add docs building
This commit is contained in:
parent
2f8c7d3083
commit
a73a8d63cf
2 changed files with 34 additions and 1 deletions
|
@ -66,6 +66,10 @@ pub enum CargoCommand<'a> {
|
|||
package: Vec<String>,
|
||||
check_only: bool,
|
||||
},
|
||||
Doc {
|
||||
cargoarg: &'a Option<&'a str>,
|
||||
features: Option<&'a str>,
|
||||
},
|
||||
ExampleSize {
|
||||
cargoarg: &'a Option<&'a str>,
|
||||
example: &'a str,
|
||||
|
@ -85,9 +89,9 @@ impl<'a> CargoCommand<'a> {
|
|||
CargoCommand::ExampleSize { .. } => "size",
|
||||
CargoCommand::Clippy { .. } => "clippy",
|
||||
CargoCommand::Format { .. } => "fmt",
|
||||
CargoCommand::Doc { .. } => "doc",
|
||||
// TODO
|
||||
// CargoCommand::Test { .. } => "test",
|
||||
// CargoCommand::Doc { .. } => "doc",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,6 +212,19 @@ impl<'a> CargoCommand<'a> {
|
|||
}
|
||||
args
|
||||
}
|
||||
CargoCommand::Doc { cargoarg, features } => {
|
||||
let mut args = vec!["+nightly"];
|
||||
if let Some(cargoarg) = cargoarg {
|
||||
args.extend_from_slice(&[cargoarg]);
|
||||
}
|
||||
|
||||
args.extend_from_slice(&[self.name()]);
|
||||
|
||||
if let Some(feature) = features {
|
||||
args.extend_from_slice(&["--features", feature]);
|
||||
}
|
||||
args
|
||||
}
|
||||
CargoCommand::Format {
|
||||
cargoarg,
|
||||
package,
|
||||
|
|
|
@ -144,6 +144,9 @@ enum Commands {
|
|||
|
||||
/// Run clippy
|
||||
Clippy(Package),
|
||||
|
||||
/// Build docs
|
||||
Doc,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
|
@ -366,6 +369,10 @@ fn main() -> anyhow::Result<()> {
|
|||
info!("Running clippy on backend: {backend:?}");
|
||||
cargo_clippy(&cargoarg, &args, backend)?;
|
||||
}
|
||||
Commands::Doc => {
|
||||
info!("Running cargo doc on backend: {backend:?}");
|
||||
cargo_doc(&cargoarg, backend)?;
|
||||
}
|
||||
Commands::FormatCheck(args) => {
|
||||
info!("Running cargo fmt: {args:?}");
|
||||
let check_only = true;
|
||||
|
@ -501,6 +508,14 @@ fn cargo_format(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cargo_doc(cargoarg: &Option<&str>, backend: Backends) -> anyhow::Result<()> {
|
||||
let s = format!("{}", backend.to_rtic_feature());
|
||||
let features: Option<&str> = Some(&s);
|
||||
|
||||
command_parser(&CargoCommand::Doc { cargoarg, features }, false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_test(
|
||||
cargoarg: &Option<&str>,
|
||||
backend: Backends,
|
||||
|
@ -701,6 +716,7 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
|
|||
| CargoCommand::Build { .. }
|
||||
| CargoCommand::Check { .. }
|
||||
| CargoCommand::Clippy { .. }
|
||||
| CargoCommand::Doc { .. }
|
||||
| CargoCommand::Format { .. }
|
||||
| CargoCommand::ExampleSize { .. } => {
|
||||
let cargo_result = run_command(command)?;
|
||||
|
|
Loading…
Reference in a new issue