Skip to content

Commit

Permalink
Auto merge of #98864 - RalfJung:rollup-ptzklyc, r=RalfJung
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - #94831 (Link to stabilization section in std-dev-guide for library tracking issue template)
 - #98764 (add Miri to the nightly docs)
 - #98773 (rustdoc: use <details> tag for the source code sidebar)
 - #98799 (Fix bug in `rustdoc -Whelp`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 3, 2022
2 parents 495b216 + ce76d73 commit 2557603
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 514 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/library_tracking_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ If the feature is changed later, please add those PRs here as well.
-->

- [ ] Implementation: #...
- [ ] Final comment period (FCP)
- [ ] Final comment period (FCP)[^1]
- [ ] Stabilization PR

<!--
Expand Down Expand Up @@ -81,3 +81,5 @@ Zulip, or the internals forum) here.
-->

- None yet.

[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html
20 changes: 12 additions & 8 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,10 @@ Available lint options:
};

println!("Lint checks provided by rustc:\n");
println!(" {} {:7.7} {}", padded("name"), "default", "meaning");
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");

let print_lints = |lints: Vec<&Lint>| {
println!(" {} {:7.7} {}", padded("name"), "default", "meaning");
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
for lint in lints {
let name = lint.name_lower().replace('_', "-");
println!(
Expand Down Expand Up @@ -884,11 +884,15 @@ Available lint options:
};

println!("Lint groups provided by rustc:\n");
println!(" {} sub-lints", padded("name"));
println!(" {} ---------", padded("----"));
println!(" {} all lints that are set to issue warnings", padded("warnings"));

let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>| {
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>, all_warnings| {
println!(" {} sub-lints", padded("name"));
println!(" {} ---------", padded("----"));

if all_warnings {
println!(" {} all lints that are set to issue warnings", padded("warnings"));
}

for (name, to) in lints {
let name = name.to_lowercase().replace('_', "-");
let desc = to
Expand All @@ -901,7 +905,7 @@ Available lint options:
println!("\n");
};

print_lint_groups(builtin_groups);
print_lint_groups(builtin_groups, true);

match (loaded_plugins, plugin.len(), plugin_groups.len()) {
(false, 0, _) | (false, _, 0) => {
Expand All @@ -916,7 +920,7 @@ Available lint options:
}
if g > 0 {
println!("Lint groups provided by plugins loaded by this crate:\n");
print_lint_groups(plugin_groups);
print_lint_groups(plugin_groups, false);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ impl<'a> Builder<'a> {
doc::RustcBook,
doc::CargoBook,
doc::Clippy,
doc::Miri,
doc::EmbeddedBook,
doc::EditionGuide,
),
Expand Down
34 changes: 29 additions & 5 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ impl Step for Rustc {
}

macro_rules! tool_doc {
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => {
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?], in_tree = $in_tree:expr $(,)?) => {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $tool {
target: TargetSelection,
Expand Down Expand Up @@ -699,6 +699,12 @@ macro_rules! tool_doc {
t!(fs::create_dir_all(&out_dir));
t!(symlink_dir_force(&builder.config, &out, &out_dir));

let source_type = if $in_tree == true {
SourceType::InTree
} else {
SourceType::Submodule
};

// Build cargo command.
let mut cargo = prepare_tool_cargo(
builder,
Expand All @@ -707,7 +713,7 @@ macro_rules! tool_doc {
target,
"doc",
$path,
SourceType::InTree,
source_type,
&[],
);

Expand All @@ -723,20 +729,38 @@ macro_rules! tool_doc {
cargo.rustdocflag("--show-type-layout");
cargo.rustdocflag("--generate-link-to-definition");
cargo.rustdocflag("-Zunstable-options");
builder.run(&mut cargo.into());
if $in_tree == true {
builder.run(&mut cargo.into());
} else {
// Allow out-of-tree docs to fail (since the tool might be in a broken state).
if !builder.try_run(&mut cargo.into()) {
builder.info(&format!(
"WARNING: tool {} failed to document; ignoring failure because it is an out-of-tree tool",
stringify!($tool).to_lowercase(),
));
}
}
}
}
}
}

tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"]);
tool_doc!(
Rustdoc,
"rustdoc-tool",
"src/tools/rustdoc",
["rustdoc", "rustdoc-json-types"],
in_tree = true
);
tool_doc!(
Rustfmt,
"rustfmt-nightly",
"src/tools/rustfmt",
["rustfmt-nightly", "rustfmt-config_proc_macro"],
in_tree = true
);
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"], in_tree = true);
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"], in_tree = false);

#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorIndex {
Expand Down
22 changes: 10 additions & 12 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,7 @@ impl Options {
print_flag_list("-C", config::CG_OPTIONS);
return Err(0);
}
let w_flags = matches.opt_strs("W");
if w_flags.iter().any(|x| *x == "help") {
print_flag_list("-W", config::DB_OPTIONS);
return Err(0);
}

if matches.opt_strs("passes") == ["list"] {
println!("Available passes for running rustdoc:");
for pass in passes::PASSES {
Expand Down Expand Up @@ -439,15 +435,19 @@ impl Options {
return Err(0);
}

if matches.free.is_empty() {
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);

let input = PathBuf::from(if describe_lints {
"" // dummy, this won't be used
} else if matches.free.is_empty() {
diag.struct_err("missing file operand").emit();
return Err(1);
}
if matches.free.len() > 1 {
} else if matches.free.len() > 1 {
diag.struct_err("too many file operands").emit();
return Err(1);
}
let input = PathBuf::from(&matches.free[0]);
} else {
&matches.free[0]
});

let libs = matches
.opt_strs("L")
Expand Down Expand Up @@ -698,8 +698,6 @@ impl Options {
let with_examples = matches.opt_strs("with-examples");
let call_locations = crate::scrape_examples::load_call_locations(with_examples, &diag)?;

let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);

Ok(Options {
input,
proc_macro_crate,
Expand Down
37 changes: 11 additions & 26 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1578,38 +1578,23 @@ kbd {
margin-bottom: 1em;
}

div.children {
padding-left: 27px;
display: none;
details.dir-entry {
padding-left: 4px;
}
div.name {

details.dir-entry > summary {
margin: 0 0 0 13px;
list-style-position: outside;
cursor: pointer;
position: relative;
margin-left: 16px;
}
div.files > a {
display: block;
padding: 0 3px;
}
div.files > a:hover, div.name:hover {
background-color: #a14b4b;

details.dir-entry div.folders, details.dir-entry div.files {
padding-left: 23px;
}
div.name.expand + .children {

details.dir-entry a {
display: block;
}
div.name::before {
content: "\25B6";
padding-left: 4px;
font-size: 0.625rem;
position: absolute;
left: -16px;
top: 4px;
}
div.name.expand::before {
transform: rotate(90deg);
left: -15px;
top: 2px;
}

/* The hideme class is used on summary tags that contain a span with
placeholder text shown only when the toggle is closed. For instance,
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,12 @@ kbd {
color: #fff;
border-bottom-color: #5c6773;
}
#source-sidebar div.files > a:hover, div.name:hover {
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #14191f;
color: #ffb44c;
}
#source-sidebar div.files > .selected {
#source-sidebar div.files > a.selected {
background-color: #14191f;
color: #ffb44c;
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ kbd {
#source-sidebar > .title {
border-bottom-color: #ccc;
}
#source-sidebar div.files > a:hover, div.name:hover {
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #444;
}
#source-sidebar div.files > .selected {
#source-sidebar div.files > a.selected {
background-color: #333;
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@ kbd {
#source-sidebar > .title {
border-bottom-color: #ccc;
}
#source-sidebar div.files > a:hover, div.name:hover {
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #E0E0E0;
}
#source-sidebar div.files > .selected {
#source-sidebar div.files > a.selected {
background-color: #fff;
}

.scraped-example-list .scrape-help {
border-color: #555;
color: #333;
Expand Down
31 changes: 12 additions & 19 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* global sourcesIndex */

// Local js definitions:
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage */

"use strict";
Expand All @@ -13,33 +13,27 @@ const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-p
let oldScrollPosition = 0;

function createDirEntry(elem, parent, fullPath, hasFoundFile) {
const name = document.createElement("div");
name.className = "name";
const dirEntry = document.createElement("details");
const summary = document.createElement("summary");

dirEntry.className = "dir-entry";

fullPath += elem["name"] + "/";

name.onclick = ev => {
if (hasClass(ev.target, "expand")) {
removeClass(ev.target, "expand");
} else {
addClass(ev.target, "expand");
}
};
name.innerText = elem["name"];
summary.innerText = elem["name"];
dirEntry.appendChild(summary);

const children = document.createElement("div");
children.className = "children";
const folders = document.createElement("div");
folders.className = "folders";
if (elem.dirs) {
for (const dir of elem.dirs) {
if (createDirEntry(dir, folders, fullPath, hasFoundFile)) {
addClass(name, "expand");
dirEntry.open = true;
hasFoundFile = true;
}
}
}
children.appendChild(folders);
dirEntry.appendChild(folders);

const files = document.createElement("div");
files.className = "files";
Expand All @@ -51,15 +45,14 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
const w = window.location.href.split("#")[0];
if (!hasFoundFile && w === file.href) {
file.className = "selected";
addClass(name, "expand");
dirEntry.open = true;
hasFoundFile = true;
}
files.appendChild(file);
}
}
children.appendChild(files);
parent.appendChild(name);
parent.appendChild(children);
dirEntry.appendChild(files);
parent.appendChild(dirEntry);
return hasFoundFile;
}

Expand Down
Loading

0 comments on commit 2557603

Please sign in to comment.