/
doc.rs
47 lines (43 loc) · 1.36 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
use crate::cli;
use crate::cli::DocOpts;
use std::process::Command;
//--cfg docsrs --Z unstable-options --document-hidden-items
pub fn run(opts: DocOpts) -> anyhow::Result<()> {
let mut flags = Vec::new();
if !opts.stable {
flags.push("--cfg docsrs");
}
if opts.internal {
flags.push("--Z unstable-options");
flags.push("--document-hidden-items");
}
flags.push("-Dwarnings");
std::env::set_var("RUSTDOCFLAGS", flags.join(" "));
cli::run(
Command::new(concat!(env!("CARGO_HOME"), "/bin/cargo"))
.args(if opts.stable { None } else { Some("+nightly") })
.arg("doc")
.arg("--lib")
.arg("--no-default-features")
.arg("--features=full")
.arg("--no-deps")
.arg("--workspace")
.args(if opts.internal {
&["--document-private-items"][..]
} else {
&["--exclude=pyo3-macros", "--exclude=pyo3-macros-backend"][..]
})
.args(if opts.stable {
&[][..]
} else {
&[
"-Z",
"unstable-options",
"-Z",
"rustdoc-scrape-examples=examples",
]
})
.args(if opts.open { Some("--open") } else { None }),
)?;
Ok(())
}