--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("doc")
+ .about("Build a package's documentation")
+ .arg(
+ opt("open", "Opens the docs in a browser after the operation")
+ )
+ .arg_package(
+ "Package to document",
+ "Document all packages in the workspace",
+ "Exclude packages from the build",
+ )
+ .arg(
+ opt("no-deps", "Don't build documentation for dependencies")
+ )
+ .arg_jobs()
+ .arg_targets_lib_bin(
+ "Document only this package's library",
+ "Document only the specified binary",
+ "Document all binaries",
+ )
+ .arg_release("Build artifacts in release mode, with optimizations")
+ .arg_features()
+ .arg_target_triple("Build for the target triple")
+ .arg_manifest_path()
+ .arg_message_format()
+ .arg_locked()
+ .after_help("\
+By default the documentation for the local package and all dependencies is
+built. The output is all placed in `target/doc` in rustdoc's usual format.
+
+All packages in the workspace are documented if the `--all` flag is supplied. The
+`--all` flag is automatically assumed for a virtual manifest.
+Note that `--exclude` has to be specified in conjunction with the `--all` flag.
+
+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.
+")
+}
let spec = Packages::from_flags(
args.is_present("all"),
&values(args, "exclude"),
- &values(args, "package")
+ &values(args, "package"),
)?;
let release = mode == CompileMode::Bench || args.is_present("release");
Some(profile) => {
let err = format_err!("unknown profile: `{}`, only `test` is \
currently supported", profile);
- return Err(CliError::new(err, 101))
+ return Err(CliError::new(err, 101));
}
};
let mode = CompileMode::Check { test };
ops::clean(&ws, &opts)?;
return Ok(());
}
+ ("doc", Some(args)) => {
+ config_from_args(config, args)?;
+ let ws = workspace_from_args(config, args)?;
+ let mode = ops::CompileMode::Doc { deps: !args.is_present("no-deps") };
+ let compile_opts = compile_options_from_args(config, args, mode)?;
+ let doc_opts = ops::DocOptions {
+ open_result: args.is_present("open"),
+ compile_opts,
+ };
+ ops::doc(&ws, &doc_opts)?;
+ return Ok(());
+ }
_ => return Ok(())
}
}
build::cli(),
check::cli(),
clean::cli(),
+ doc::cli(),
])
;
app
mod build;
mod check;
mod clean;
+mod doc;
mod utils {
use clap::{self, SubCommand, AppSettings};
)
}
- fn arg_target(
+ fn arg_targets_all(
self,
lib: &'static str,
bin: &'static str,
benchs: &'static str,
all: &'static str,
) -> Self {
- self._arg(opt("lib", lib))
- ._arg(opt("bin", bin).value_name("NAME").multiple(true))
- ._arg(opt("bins", bins))
+ self.arg_targets_lib_bin(lib, bin, bins)
._arg(opt("example", examle).value_name("NAME").multiple(true))
._arg(opt("examples", examles))
._arg(opt("test", test).value_name("NAME").multiple(true))
._arg(opt("all-targets", all))
}
+ fn arg_targets_lib_bin(
+ self,
+ lib: &'static str,
+ bin: &'static str,
+ bins: &'static str,
+ ) -> Self {
+ self._arg(opt("lib", lib))
+ ._arg(opt("bin", bin).value_name("NAME").multiple(true))
+ ._arg(opt("bins", bins))
+ }
+
fn arg_features(self) -> Self {
self
._arg(