about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-01-30 15:11:46 +0530
committerGitHub <noreply@github.com>2023-01-30 15:11:46 +0530
commitd94698cb378feb86e1309eb913bad603cf2089e8 (patch)
tree460737560a7a6036e5d2bbce8b444cd84a630333
parente19ae977ec4c8eaccd92c8e16da4ca4d6ca318d5 (diff)
parent8f84408697dfa95fd3b6367094105b959969702e (diff)
downloadrust-d94698cb378feb86e1309eb913bad603cf2089e8.tar.gz
rust-d94698cb378feb86e1309eb913bad603cf2089e8.zip
Rollup merge of #107264 - ferrocene:pa-private-items, r=Mark-Simulacrum
Add option to include private items in library docs

I need to perform some one-off analysis on libcore, and I wanted to use the unstable JSON rustdoc output to easily do it. Unfortunately, there is currently no way to include unstable items in the library docs. This PR adds support for that, with the off-by-default `build.library-docs-private-items` setting.
-rw-r--r--config.toml.example3
-rw-r--r--src/bootstrap/config.rs3
-rw-r--r--src/bootstrap/doc.rs3
3 files changed, 9 insertions, 0 deletions
diff --git a/config.toml.example b/config.toml.example
index 299bfd779e5..85f058f3664 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -233,6 +233,9 @@ changelog-seen = 2
 # and generated in already-minified form from the beginning.
 #docs-minification = true
 
+# Flag to specify whether private items should be included in the library docs.
+#library-docs-private-items = false
+
 # Indicate whether the compiler should be documented in addition to the standard
 # library and facade crates.
 #compiler-docs = false
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index fdd659c60ca..165502b0a41 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -65,6 +65,7 @@ pub struct Config {
     pub verbose: usize,
     pub submodules: Option<bool>,
     pub compiler_docs: bool,
+    pub library_docs_private_items: bool,
     pub docs_minification: bool,
     pub docs: bool,
     pub locked_deps: bool,
@@ -606,6 +607,7 @@ define_config! {
         rustfmt: Option<PathBuf> = "rustfmt",
         docs: Option<bool> = "docs",
         compiler_docs: Option<bool> = "compiler-docs",
+        library_docs_private_items: Option<bool> = "library-docs-private-items",
         docs_minification: Option<bool> = "docs-minification",
         submodules: Option<bool> = "submodules",
         gdb: Option<String> = "gdb",
@@ -1018,6 +1020,7 @@ impl Config {
         config.submodules = build.submodules;
         set(&mut config.low_priority, build.low_priority);
         set(&mut config.compiler_docs, build.compiler_docs);
+        set(&mut config.library_docs_private_items, build.library_docs_private_items);
         set(&mut config.docs_minification, build.docs_minification);
         set(&mut config.docs, build.docs);
         set(&mut config.locked_deps, build.locked_deps);
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 9bad9046ecc..7f8aa2573dd 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -597,6 +597,9 @@ fn doc_std(
             .arg("--resource-suffix")
             .arg(&builder.version)
             .args(extra_args);
+        if builder.config.library_docs_private_items {
+            cargo.arg("--document-private-items").arg("--document-hidden-items");
+        }
         builder.run(&mut cargo.into());
     };