Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate error index with mdbook instead of raw HTML pages #101166

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ dependencies = [
name = "error_index_generator"
version = "0.0.0"
dependencies = [
"rustdoc",
"mdbook",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl Step for ErrorIndex {
t!(fs::create_dir_all(&out));
let mut index = tool::ErrorIndex::command(builder);
index.arg("html");
index.arg(out.join("error-index.html"));
index.arg(out);
index.arg(&builder.version);

builder.run(&mut index);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/error_index_generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
edition = "2021"

[dependencies]
rustdoc = { path = "../../librustdoc" }
mdbook = { version = "0.4", default-features = false, features = ["search"] }

[[bin]]
name = "error_index_generator"
Expand Down
19 changes: 19 additions & 0 deletions src/tools/error_index_generator/book_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[book]
title = "Error codes index"
description = "Book listing all Rust error codes"
src = ""

[output.html]
git-repository-url = "https://github.com/rust-lang/rust/"
additional-css = ["error-index.css"]
additional-js = ["error-index.js"]

[output.html.search]
enable = true
limit-results = 20
use-boolean-and = true
boost-title = 2
boost-hierarchy = 2
boost-paragraph = 1
expand = true
heading-split-level = 0
38 changes: 38 additions & 0 deletions src/tools/error_index_generator/error-index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
code.compile_fail {
border-left: 2px solid red;
}

pre .tooltip {
position: absolute;
left: -25px;
top: 0;
z-index: 1;
color: red;
cursor: pointer;
}
pre .tooltip::after {
display: none;
content: "This example deliberately fails to compile";
background-color: #000;
color: #fff;
border-color: #000;
text-align: center;
padding: 5px 3px 3px 3px;
border-radius: 6px;
margin-left: 5px;
}
pre .tooltip::before {
display: none;
border-color: transparent black transparent transparent;
content: " ";
position: absolute;
top: 50%;
left: 16px;
margin-top: -5px;
border-width: 5px;
border-style: solid;
}

pre .tooltip:hover::before, pre .tooltip:hover::after {
display: inline;
}
9 changes: 9 additions & 0 deletions src/tools/error_index_generator/error-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
for (const elem of document.querySelectorAll("pre.playground")) {
if (elem.querySelector(".compile_fail") === null) {
continue;
}
const child = document.createElement("div");
child.className = "tooltip";
child.textContent = "ⓘ";
elem.appendChild(child);
}
Loading