Rollup merge of #87035 - GuillaumeGomez:fix-implementors-display, r=notriddle
Fix implementors display Part of https://github.com/rust-lang/rust/issues/86632. This PR does a few things: * It fixes of the JS rendered implementors. * It generates anchors for JS rendered implementors to make it coherent with the others. * It adds a test to ensure that we won't have the same issue again. * It changes the way we render the rustdoc-gui crates to simplify it a bit and also to allow to have dependencies without going through compiletest. Before:  After:  I plan to add the `[src]` links in another PR because this one is already big enough. cc `@Mark-Simulacrum` (for the bootstrap changes) r? `@Nemo157`
This commit is contained in:
commit
fab45bf485
13 changed files with 109 additions and 18 deletions
16
src/test/rustdoc-gui/implementors.goml
Normal file
16
src/test/rustdoc-gui/implementors.goml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// The goal of this test is to check that the external trait implementors, generated with JS,
|
||||
// have the same display than the "local" ones.
|
||||
goto: file://|DOC_PATH|/implementors/trait.Whatever.html
|
||||
assert: "#implementors-list"
|
||||
// There are supposed to be two implementors listed.
|
||||
assert-count: ("#implementors-list > .impl", 2)
|
||||
// Now we check that both implementors have an anchor, an ID and a similar DOM.
|
||||
assert: ("#implementors-list > .impl:nth-child(1) > a.anchor")
|
||||
assert-attribute: ("#implementors-list > .impl:nth-child(1)", {"id": "impl-Whatever"})
|
||||
assert-attribute: ("#implementors-list > .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever"})
|
||||
assert: "#implementors-list > .impl:nth-child(1) > code.in-band"
|
||||
|
||||
assert: ("#implementors-list > .impl:nth-child(2) > a.anchor")
|
||||
assert-attribute: ("#implementors-list > .impl:nth-child(2)", {"id": "impl-Whatever-1"})
|
||||
assert-attribute: ("#implementors-list > .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
|
||||
assert: "#implementors-list > .impl:nth-child(2) > code.in-band"
|
||||
18
src/test/rustdoc-gui/src/Cargo.lock
Normal file
18
src/test/rustdoc-gui/src/Cargo.lock
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "implementors"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "lib2"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"implementors",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test_docs"
|
||||
version = "0.1.0"
|
||||
6
src/test/rustdoc-gui/src/Cargo.toml
Normal file
6
src/test/rustdoc-gui/src/Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"test_docs",
|
||||
"lib2",
|
||||
"implementors",
|
||||
]
|
||||
7
src/test/rustdoc-gui/src/implementors/Cargo.toml
Normal file
7
src/test/rustdoc-gui/src/implementors/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "implementors"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
7
src/test/rustdoc-gui/src/implementors/lib.rs
Normal file
7
src/test/rustdoc-gui/src/implementors/lib.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub trait Whatever {
|
||||
fn method() {}
|
||||
}
|
||||
|
||||
pub struct Struct;
|
||||
|
||||
impl Whatever for Struct {}
|
||||
10
src/test/rustdoc-gui/src/lib2/Cargo.toml
Normal file
10
src/test/rustdoc-gui/src/lib2/Cargo.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "lib2"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
implementors = { path = "../implementors" }
|
||||
|
|
@ -31,3 +31,5 @@ impl Trait for Foo {
|
|||
type X = u32;
|
||||
const Y: u32 = 0;
|
||||
}
|
||||
|
||||
impl implementors::Whatever for Foo {}
|
||||
7
src/test/rustdoc-gui/src/lib2/src/lib.rs
Normal file
7
src/test/rustdoc-gui/src/lib2/src/lib.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
7
src/test/rustdoc-gui/src/test_docs/Cargo.toml
Normal file
7
src/test/rustdoc-gui/src/test_docs/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "test_docs"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
Loading…
Add table
Add a link
Reference in a new issue