Skip to content

Commit

Permalink
Rename the cfg attribute from rustdoc to doc
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 21, 2019
1 parent 086c8d3 commit a056bf9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/doc/rustdoc/src/the-doc-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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;
```

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt

let extern_names: Vec<String> = 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());
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ symbols! {
rustc_test_marker,
rustc_then_this_would_need,
rustc_variance,
rustdoc,
rustfmt,
rust_eh_personality,
rust_eh_unwind_resume,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/cfg-rustdoc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(rustdoc)]
#[cfg(doc)]
pub struct Foo;

fn main() {
Expand Down

0 comments on commit a056bf9

Please sign in to comment.