From: Aleksey Kladov Date: Thu, 8 Mar 2018 10:16:17 +0000 (+0300) Subject: Move rustdoc to clap X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~47^2~46 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ecb5b15f66a19f1dee2b7c433b0879b332bdf44d;p=cargo.git Move rustdoc to clap --- diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 81be94cd8..ae1928e48 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -92,7 +92,7 @@ fn main() { "build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" | "git-checkout" | "init" | "install" | "locate-project" | "login" | "metadata" | "new" | "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" | - "rustc" => true, + "rustc" | "rustdoc" => true, _ => false }); @@ -142,7 +142,7 @@ macro_rules! each_subcommand{ // $mac!(read_manifest); // $mac!(run); // $mac!(rustc); - $mac!(rustdoc); +// $mac!(rustdoc); $mac!(search); $mac!(test); $mac!(uninstall); diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 25d9aeb2f..a1b0125ce 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -514,6 +514,20 @@ about this warning."; ops::compile(&ws, &compile_opts)?; return Ok(()); } + ("rustdoc", Some(args)) => { + let ws = workspace_from_args(config, args)?; + let mode = CompileMode::Doc { deps: false }; + let mut compile_opts = compile_options_from_args(config, args, mode)?; + let packages = values(args, "package"); + compile_opts.spec = Packages::Packages(&packages); + compile_opts.target_rustdoc_args = Some(&values(args, "args")); + let doc_opts = ops::DocOptions { + open_result: args.is_present("open"), + compile_opts + }; + ops::doc(&ws, &doc_opts)?; + return Ok(()); + } _ => return Ok(()) } } @@ -604,6 +618,7 @@ See 'cargo help ' for more information on a specific command. read_manifest::cli(), run::cli(), rustc::cli(), + rustdoc::cli(), ]) ; app @@ -633,6 +648,7 @@ mod publish; mod read_manifest; mod run; mod rustc; +mod rustdoc; mod utils { use clap::{self, SubCommand, AppSettings}; diff --git a/src/bin/cli/rustdoc.rs b/src/bin/cli/rustdoc.rs new file mode 100644 index 000000000..031dbbbd1 --- /dev/null +++ b/src/bin/cli/rustdoc.rs @@ -0,0 +1,44 @@ +use clap::AppSettings; + +use super::utils::*; + +pub fn cli() -> App { + subcommand("rustdoc") + .setting(AppSettings::TrailingVarArg) + .about("Build a package's documentation, using specified custom flags.") + .arg(Arg::with_name("args").multiple(true)) + .arg(opt("open", "Opens the docs in a browser after the operation")) + .arg( + opt("package", "Package to document") + .short("p").value_name("SPEC") + ) + .arg_jobs() + .arg_targets_all( + "Build only this package's library", + "Build only the specified binary", + "Build all binaries", + "Build only the specified example", + "Build all examples", + "Build only the specified test target", + "Build all tests", + "Build only the specified bench target", + "Build all benches", + "Build all targets (default)", + ) + .arg_release("Build artifacts in release mode, with optimizations") + .arg_manifest_path() + .arg_message_format() + .after_help("\ +The specified target for the current package (or package specified by SPEC if +provided) will be documented with the specified ... being passed to the +final rustdoc invocation. Dependencies will not be documented as part of this +command. Note that rustdoc will still unconditionally receive arguments such +as -L, --extern, and --crate-type, and the specified ... will simply be +added to the rustdoc invocation. + +If the --package argument is given, then SPEC is a package id specification +which indicates which package should be documented. If it is not given, then the +current package is documented. For more information on SPEC and its format, see +the `cargo help pkgid` command. +") +}