From a056bf9714fca847494ee6aa6025acb1a7fdd852 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 6 Nov 2019 14:48:10 +0100 Subject: [PATCH] Rename the cfg attribute from rustdoc to doc --- src/doc/rustdoc/src/the-doc-attribute.md | 10 +++++----- src/librustdoc/core.rs | 2 +- src/libsyntax_pos/symbol.rs | 1 - src/test/ui/cfg-rustdoc.rs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/doc/rustdoc/src/the-doc-attribute.md b/src/doc/rustdoc/src/the-doc-attribute.md index 3aaac9268ff..5fac0bddc3b 100644 --- a/src/doc/rustdoc/src/the-doc-attribute.md +++ b/src/doc/rustdoc/src/the-doc-attribute.md @@ -215,7 +215,7 @@ Since primitive types are defined in the compiler, there's no place to attach do attributes. This attribute is used by the standard library to provide a way to generate documentation for primitive types. -## `#[cfg(rustdoc)]`: Documenting platform-/feature-specific information +## `#[cfg(doc)]`: Documenting platform-/feature-specific information For conditional compilation, Rustdoc treats your crate the same way the compiler does: Only things from the host target are available (or from the given `--target` if present), and everything else is @@ -224,9 +224,9 @@ on different targets and you want your documentation to reflect all the availabl provide. If you want to make sure an item is seen by Rustdoc regardless of what platform it's targeting, -you can apply `#[cfg(rustdoc)]` to it. Rustdoc sets this whenever it's building documentation, so +you can apply `#[cfg(doc)]` to it. Rustdoc sets this whenever it's building documentation, so anything that uses that flag will make it into documentation it generates. To apply this to an item -with other `#[cfg]` filters on it, you can write something like `#[cfg(any(windows, rustdoc))]`. +with other `#[cfg]` filters on it, you can write something like `#[cfg(any(windows, doc))]`. This will preserve the item either when built normally on Windows, or when being documented anywhere. @@ -236,10 +236,10 @@ Example: ```rust /// Token struct that can only be used on Windows. -#[cfg(any(windows, rustdoc))] +#[cfg(any(windows, doc))] pub struct WindowsToken; /// Token struct that can only be used on Unix. -#[cfg(any(unix, rustdoc))] +#[cfg(any(unix, doc))] pub struct UnixToken; ``` diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 2b4ac7676fa..612f3c69871 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -250,7 +250,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let extern_names: Vec = externs.iter().map(|(s,_)| s).cloned().collect(); - // Add the rustdoc cfg into the doc build. + // Add the doc cfg into the doc build. cfgs.push("doc".to_string()); let cpath = Some(input.clone()); diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 1139bf67a36..cab82f8c61b 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -624,7 +624,6 @@ symbols! { rustc_test_marker, rustc_then_this_would_need, rustc_variance, - rustdoc, rustfmt, rust_eh_personality, rust_eh_unwind_resume, diff --git a/src/test/ui/cfg-rustdoc.rs b/src/test/ui/cfg-rustdoc.rs index a8e0c87eff8..dd8e1ed97c4 100644 --- a/src/test/ui/cfg-rustdoc.rs +++ b/src/test/ui/cfg-rustdoc.rs @@ -1,4 +1,4 @@ -#[cfg(rustdoc)] +#[cfg(doc)] pub struct Foo; fn main() {