Skip to content

Commit 392db56

Browse files
committed
doc: enhancement of -Zrustdoc-map
1 parent 2fa38a2 commit 392db56

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/cargo/core/compiler/rustdoc.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use url::Url;
1313

1414
const DOCS_RS_URL: &'static str = "https://docs.rs/";
1515

16-
/// Mode used for `std`.
16+
/// Mode used for `std`. This is for unstable feature [`-Zrustdoc-map`][1].
17+
///
18+
/// [1]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map
1719
#[derive(Debug, Hash)]
1820
pub enum RustdocExternMode {
1921
/// Use a local `file://` URL.
@@ -54,11 +56,17 @@ impl<'de> serde::de::Deserialize<'de> for RustdocExternMode {
5456
}
5557
}
5658

59+
/// A map of registry names to URLs where documentations are hosted.
60+
/// This is for unstable feature [`-Zrustdoc-map`][1].
61+
///
62+
/// [1]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map
5763
#[derive(serde::Deserialize, Debug)]
5864
#[serde(default)]
5965
pub struct RustdocExternMap {
6066
#[serde(deserialize_with = "default_crates_io_to_docs_rs")]
61-
pub(crate) registries: HashMap<String, String>,
67+
/// * Key is the registry name in the configuration `[registries.<name>]`.
68+
/// * Value is the URL where the documentation is hosted.
69+
registries: HashMap<String, String>,
6270
std: Option<RustdocExternMode>,
6371
}
6472

@@ -92,6 +100,11 @@ impl hash::Hash for RustdocExternMap {
92100
}
93101
}
94102

103+
/// Adds unstable flag [`--extern-html-root-url`][1] to the given `rustdoc`
104+
/// invocation. This is for unstable feature [`-Zrustdoc-map`][2].
105+
///
106+
/// [1]: https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#--extern-html-root-url-control-how-rustdoc-links-to-non-local-crates
107+
/// [2]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map
95108
pub fn add_root_urls(
96109
cx: &Context<'_, '_>,
97110
unit: &Unit,
@@ -191,8 +204,11 @@ pub fn add_root_urls(
191204
Ok(())
192205
}
193206

194-
/// Indicates whether a target should have examples scraped from it
195-
/// by rustdoc. Configured within Cargo.toml.
207+
/// Indicates whether a target should have examples scraped from it by rustdoc.
208+
/// Configured within Cargo.toml and only for unstable feature
209+
/// [`-Zrustdoc-scrape-examples`][1].
210+
///
211+
/// [1]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#scrape-examples
196212
#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug, Copy)]
197213
pub enum RustdocScrapeExamples {
198214
Enabled,

0 commit comments

Comments
 (0)