Link to the corresponding channel in the help popover

This commit is contained in:
Guillaume Gomez 2023-06-23 16:20:57 +02:00
parent 2f3bed0c4c
commit 2f1939ab8b
4 changed files with 12 additions and 5 deletions

View File

@ -21,6 +21,7 @@
use rustc_span::symbol::{kw, sym, Symbol};
use std::fmt::Write as _;
use std::mem;
use std::sync::LazyLock as Lazy;
use thin_vec::{thin_vec, ThinVec};
#[cfg(test)]
@ -582,6 +583,8 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
///
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit("/").filter(|c| !c.is_empty()).next().unwrap());
/// Render a sequence of macro arms in a format suitable for displaying to the user
/// as part of an item declaration.

View File

@ -55,6 +55,7 @@ struct PageLayout<'a> {
sidebar: String,
content: String,
krate_with_trailing_slash: String,
rust_channel: &'static str,
pub(crate) rustdoc_version: &'a str,
}
@ -82,6 +83,7 @@ pub(crate) fn render<T: Print, S: Print>(
sidebar,
content,
krate_with_trailing_slash,
rust_channel: *crate::clean::utils::DOC_CHANNEL,
rustdoc_version,
}
.render()

View File

@ -1050,9 +1050,10 @@ function preLoadCss(cssUrl) {
function buildHelpMenu() {
const book_info = document.createElement("span");
const channel = getVar("channel");
book_info.className = "top";
book_info.innerHTML = "You can find more information in \
<a href=\"https://doc.rust-lang.org/rustdoc/\">the rustdoc book</a>.";
book_info.innerHTML = `You can find more information in \
<a href="https://doc.rust-lang.org/${channel}/rustdoc/">the rustdoc book</a>.`;
const shortcuts = [
["?", "Show this help dialog"],
@ -1072,9 +1073,9 @@ function preLoadCss(cssUrl) {
div_shortcuts.innerHTML = "<h2>Keyboard Shortcuts</h2><dl>" + shortcuts + "</dl></div>";
const infos = [
"For a full list of all search features, take a look <a \
href='https://doc.rust-lang.org/stable/rustdoc/how-to-read-rustdoc.html\
#the-search-interface'>here</a>.",
`For a full list of all search features, take a look <a \
href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
#the-search-interface">here</a>.`,
"Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to \
restrict the search to a given item kind.",
"Accepted kinds are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \

View File

@ -31,6 +31,7 @@
data-themes="{{themes|join(",") }}" {#+ #}
data-resource-suffix="{{page.resource_suffix}}" {#+ #}
data-rustdoc-version="{{rustdoc_version}}" {#+ #}
data-channel="{{rust_channel}}" {#+ #}
data-search-js="{{files.search_js}}" {#+ #}
data-settings-js="{{files.settings_js}}" {#+ #}
data-settings-css="{{files.settings_css}}" {#+ #}