Rollup merge of #53076 - QuietMisdreavus:cfg-rustdoc, r=GuillaumeGomez
set cfg(rustdoc) when rustdoc is running on a crate When using `#[doc(cfg)]` to document platform-specific items, it's a little cumbersome to get all the platforms' items to appear all at once. For example, the standard library adds `--cfg dox` to rustdoc's command line whenever it builds docs, and the documentation for `#![feature(doc_cfg)]` suggests using a Cargo feature to approximate the same thing. This is a little awkward, because you always need to remember to set `--features dox` whenever you build documentation. This PR proposes making rustdoc set `#[cfg(rustdoc)]` whenever it runs on a crate, to provide an officially-sanctioned version of this that is set automatically. This way, there's a standardized way to declare that a certain version of an item is specifically when building docs. To try to prevent the spread of this feature from happening too quickly, this PR also restricts the use of this flag to whenever `#![feature(doc_cfg)]` is active. I'm sure there are other uses for this, but right now i'm tying it to this feature. (If it makes more sense to give this its own feature, i can easily do that.)
This commit is contained in:
commit
d0f8cf32b3
13 changed files with 68 additions and 36 deletions
|
@ -477,7 +477,8 @@ fn main_args(args: &[String]) -> isize {
|
|||
|
||||
let output = matches.opt_str("o").map(|s| PathBuf::from(&s));
|
||||
let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s));
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
let mut cfgs = matches.opt_strs("cfg");
|
||||
cfgs.push("rustdoc".to_string());
|
||||
|
||||
if let Some(ref p) = css_file_extension {
|
||||
if !p.is_file() {
|
||||
|
@ -671,7 +672,8 @@ where R: 'static + Send,
|
|||
for s in &matches.opt_strs("L") {
|
||||
paths.add_path(s, ErrorOutputType::default());
|
||||
}
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
let mut cfgs = matches.opt_strs("cfg");
|
||||
cfgs.push("rustdoc".to_string());
|
||||
let triple = matches.opt_str("target").map(|target| {
|
||||
if target.ends_with(".json") {
|
||||
TargetTriple::TargetPath(PathBuf::from(target))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue