]>
Commit | Line | Data |
---|---|---|
293a2a7f | 1 | use cargo::ops::{self, DocOptions}; |
6b9c063b | 2 | |
f7c91ba6 AR |
3 | use crate::command_prelude::*; |
4 | ||
ecb5b15f AK |
5 | pub fn cli() -> App { |
6 | subcommand("rustdoc") | |
7 | .setting(AppSettings::TrailingVarArg) | |
8 | .about("Build a package's documentation, using specified custom flags.") | |
e873e4e9 | 9 | .arg(opt("quiet", "No output printed to stdout").short("q")) |
ecb5b15f | 10 | .arg(Arg::with_name("args").multiple(true)) |
1e682848 AC |
11 | .arg(opt( |
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() |
1e682848 AC |
37 | .after_help( |
38 | "\ | |
ecb5b15f | 39 | The specified target for the current package (or package specified by SPEC if |
f7c91ba6 | 40 | provided) will be documented with the specified `<opts>...` being passed to the |
ecb5b15f | 41 | final rustdoc invocation. Dependencies will not be documented as part of this |
f7c91ba6 AR |
42 | command. Note that rustdoc will still unconditionally receive arguments such |
43 | as `-L`, `--extern`, and `--crate-type`, and the specified `<opts>...` will | |
44 | simply be added to the rustdoc invocation. | |
ecb5b15f | 45 | |
f7c91ba6 | 46 | If the `--package` argument is given, then SPEC is a package ID specification |
ecb5b15f AK |
47 | which indicates which package should be documented. If it is not given, then the |
48 | current package is documented. For more information on SPEC and its format, see | |
49 | the `cargo help pkgid` command. | |
1e682848 AC |
50 | ", |
51 | ) | |
ecb5b15f | 52 | } |
6b9c063b | 53 | |
6d1d3a68 | 54 | pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { |
6b9c063b | 55 | let ws = args.workspace(config)?; |
db09895f | 56 | let mut compile_opts = args.compile_options_for_single_package( |
57 | config, | |
58 | CompileMode::Doc { deps: false }, | |
59 | Some(&ws), | |
2f81adb1 | 60 | ProfileChecking::Checked, |
db09895f | 61 | )?; |
3e07a3e6 XL |
62 | let target_args = values(args, "args"); |
63 | compile_opts.target_rustdoc_args = if target_args.is_empty() { | |
64 | None | |
65 | } else { | |
66 | Some(target_args) | |
67 | }; | |
6b9c063b AK |
68 | let doc_opts = DocOptions { |
69 | open_result: args.is_present("open"), | |
70 | compile_opts, | |
71 | }; | |
72 | ops::doc(&ws, &doc_opts)?; | |
73 | Ok(()) | |
74 | } |