]> git.proxmox.com Git - cargo.git/blame - src/bin/cargo/commands/rustdoc.rs
New upstream version 0.66.0
[cargo.git] / src / bin / cargo / commands / rustdoc.rs
CommitLineData
293a2a7f 1use cargo::ops::{self, DocOptions};
6b9c063b 2
f7c91ba6
AR
3use crate::command_prelude::*;
4
ecb5b15f
AK
5pub fn cli() -> App {
6 subcommand("rustdoc")
f78ffb9f 7 .trailing_var_arg(true)
ecb5b15f 8 .about("Build a package's documentation, using specified custom flags.")
a3e3ff99 9 .arg_quiet()
92fa72d4 10 .arg(Arg::new("args").multiple_values(true))
fc0ca1e1 11 .arg(flag(
1e682848
AC
12 "open",
13 "Opens the docs in a browser after the operation",
14 ))
70ff33a5 15 .arg_package("Package to document")
ecb5b15f
AK
16 .arg_jobs()
17 .arg_targets_all(
18 "Build only this package's library",
19 "Build only the specified binary",
20 "Build all binaries",
21 "Build only the specified example",
22 "Build all examples",
23 "Build only the specified test target",
24 "Build all tests",
25 "Build only the specified bench target",
26 "Build all benches",
3a1cad6f 27 "Build all targets",
ecb5b15f
AK
28 )
29 .arg_release("Build artifacts in release mode, with optimizations")
86c459d4 30 .arg_profile("Build artifacts with the specified profile")
31e6c968 31 .arg_features()
a118cdb1 32 .arg_target_triple("Build for the target triple")
dd0b7a2c 33 .arg_target_dir()
ecb5b15f
AK
34 .arg_manifest_path()
35 .arg_message_format()
aa80a984 36 .arg_unit_graph()
c221fec9 37 .arg_ignore_rust_version()
c0669189 38 .arg_timings()
0e26eae5 39 .after_help("Run `cargo help rustdoc` for more detailed information.\n")
ecb5b15f 40}
6b9c063b 41
f17ecafc 42pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
6b9c063b 43 let ws = args.workspace(config)?;
db09895f 44 let mut compile_opts = args.compile_options_for_single_package(
45 config,
46 CompileMode::Doc { deps: false },
47 Some(&ws),
73dba767 48 ProfileChecking::Custom,
db09895f 49 )?;
3e07a3e6
XL
50 let target_args = values(args, "args");
51 compile_opts.target_rustdoc_args = if target_args.is_empty() {
52 None
53 } else {
54 Some(target_args)
55 };
6b9c063b 56 let doc_opts = DocOptions {
fc0ca1e1 57 open_result: args.flag("open"),
6b9c063b
AK
58 compile_opts,
59 };
60 ops::doc(&ws, &doc_opts)?;
61 Ok(())
62}