xtask: Add doc task
Mirror the task in CI
This commit is contained in:
parent
9a401cefae
commit
1f23e8abcb
41
xtask/src/doc.rs
Normal file
41
xtask/src/doc.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use clap::Args;
|
||||
|
||||
use crate::{cmd, Result};
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct DocTask {
|
||||
/// Open the browser when the docs are built.
|
||||
#[clap(long)]
|
||||
pub open: bool,
|
||||
|
||||
/// Fail on warnings.
|
||||
#[clap(long)]
|
||||
pub deny_warnings: bool,
|
||||
}
|
||||
|
||||
impl DocTask {
|
||||
pub(crate) fn run(self) -> Result<()> {
|
||||
let mut rustdocflags = "--enable-index-page -Zunstable-options --cfg docsrs".to_owned();
|
||||
if self.deny_warnings {
|
||||
rustdocflags += " -Dwarnings";
|
||||
}
|
||||
|
||||
// Keep in sync with .github/workflows/docs.yml
|
||||
let mut cmd = cmd!(
|
||||
"
|
||||
rustup run nightly cargo doc --no-deps --workspace
|
||||
--exclude ruma-macros --exclude ruma-identifiers-validation --exclude xtask
|
||||
--all-features -Zrustdoc-map
|
||||
"
|
||||
)
|
||||
.env("RUSTDOCFLAGS", rustdocflags);
|
||||
|
||||
if self.open {
|
||||
cmd = cmd.arg("--open");
|
||||
}
|
||||
|
||||
cmd.run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -14,12 +14,14 @@ use serde_json::from_str as from_json_str;
|
||||
#[cfg(feature = "default")]
|
||||
mod cargo;
|
||||
mod ci;
|
||||
mod doc;
|
||||
#[cfg(feature = "default")]
|
||||
mod release;
|
||||
#[cfg(feature = "default")]
|
||||
mod util;
|
||||
|
||||
use ci::{CiArgs, CiTask};
|
||||
use doc::DocTask;
|
||||
#[cfg(feature = "default")]
|
||||
use release::{ReleaseArgs, ReleaseTask};
|
||||
|
||||
@ -35,6 +37,8 @@ struct Xtask {
|
||||
enum Command {
|
||||
/// Run continuous integration checks
|
||||
Ci(CiArgs),
|
||||
/// Build the docs
|
||||
Doc(DocTask),
|
||||
/// Publish a new version of a crate on crates.io, `publish` can be used as an alias
|
||||
#[cfg(feature = "default")]
|
||||
#[clap(alias = "publish")]
|
||||
@ -47,6 +51,7 @@ fn main() -> Result<()> {
|
||||
let ci = CiTask::new(args.cmd)?;
|
||||
ci.run()
|
||||
}
|
||||
Command::Doc(doc) => doc.run(),
|
||||
#[cfg(feature = "default")]
|
||||
Command::Release(args) => {
|
||||
let mut task = ReleaseTask::new(args.package, args.version)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user