forked from rust-lang/cargo
/
doc.rs
57 lines (53 loc) · 1.94 KB
/
doc.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::command_prelude::*;
use cargo::ops::{self, DocOptions};
pub fn cli() -> App {
subcommand("doc")
// subcommand aliases are handled in aliased_command()
// .alias("d")
.about("Build a package's documentation")
.arg_quiet()
.arg(opt(
"open",
"Opens the docs in a browser after the operation",
))
.arg_package_spec(
"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(opt("document-private-items", "Document private items"))
.arg_jobs()
.arg_targets_lib_bin_example(
"Document only this package's library",
"Document only the specified binary",
"Document all binaries",
"Document only the specified example",
"Document all examples",
)
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_features()
.arg_target_triple("Build for the target triple")
.arg_target_dir()
.arg_manifest_path()
.arg_message_format()
.arg_ignore_rust_version()
.arg_unit_graph()
.after_help("Run `cargo help doc` for more detailed information.\n")
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let ws = args.workspace(config)?;
let mode = CompileMode::Doc {
deps: !args.is_present("no-deps"),
};
let mut compile_opts =
args.compile_options(config, mode, Some(&ws), ProfileChecking::Custom)?;
compile_opts.rustdoc_document_private_items = args.is_present("document-private-items");
let doc_opts = DocOptions {
open_result: args.is_present("open"),
compile_opts,
};
ops::doc(&ws, &doc_opts)?;
Ok(())
}