Skip to content

Commit 1171697

Browse files
Generate error index with mdbook instead of raw HTML pages
1 parent 7a42ca9 commit 1171697

File tree

8 files changed

+214
-141
lines changed

8 files changed

+214
-141
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ dependencies = [
12681268
name = "error_index_generator"
12691269
version = "0.0.0"
12701270
dependencies = [
1271-
"rustdoc",
1271+
"mdbook",
12721272
]
12731273

12741274
[[package]]

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl Step for ErrorIndex {
793793
t!(fs::create_dir_all(&out));
794794
let mut index = tool::ErrorIndex::command(builder);
795795
index.arg("html");
796-
index.arg(out.join("error-index.html"));
796+
index.arg(out);
797797
index.arg(&builder.version);
798798

799799
builder.run(&mut index);

src/tools/error_index_generator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
edition = "2021"
55

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

99
[[bin]]
1010
name = "error_index_generator"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[book]
2+
title = "Error codes index"
3+
description = "Book listing all Rust error codes"
4+
src = ""
5+
6+
[output.html]
7+
git-repository-url = "https://github.com/rust-lang/rust/"
8+
additional-css = ["error-index.css"]
9+
additional-js = ["error-index.js"]
10+
11+
[output.html.search]
12+
enable = true
13+
limit-results = 20
14+
use-boolean-and = true
15+
boost-title = 2
16+
boost-hierarchy = 2
17+
boost-paragraph = 1
18+
expand = true
19+
heading-split-level = 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
code.compile_fail {
2+
border-left: 2px solid red;
3+
}
4+
5+
pre .tooltip {
6+
position: absolute;
7+
left: -25px;
8+
top: 0;
9+
z-index: 1;
10+
color: red;
11+
cursor: pointer;
12+
}
13+
pre .tooltip::after {
14+
display: none;
15+
content: "This example deliberately fails to compile";
16+
background-color: #000;
17+
color: #fff;
18+
border-color: #000;
19+
text-align: center;
20+
padding: 5px 3px 3px 3px;
21+
border-radius: 6px;
22+
margin-left: 5px;
23+
}
24+
pre .tooltip::before {
25+
display: none;
26+
border-color: transparent black transparent transparent;
27+
content: " ";
28+
position: absolute;
29+
top: 50%;
30+
left: 16px;
31+
margin-top: -5px;
32+
border-width: 5px;
33+
border-style: solid;
34+
}
35+
36+
pre .tooltip:hover::before, pre .tooltip:hover::after {
37+
display: inline;
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
for (const elem of document.querySelectorAll("pre.playground")) {
2+
if (elem.querySelector(".compile_fail") === null) {
3+
continue;
4+
}
5+
const child = document.createElement("div");
6+
child.className = "tooltip";
7+
child.textContent = "ⓘ";
8+
elem.appendChild(child);
9+
}

0 commit comments

Comments
 (0)