diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-07-27 11:52:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-27 11:52:54 +0900 |
| commit | 181bf05d86d906e5a8eea51f8fd702deb7a706cc (patch) | |
| tree | 9e06cd8304fdc8584ad288984d6fe7ff05c3e372 | |
| parent | 3ca1c3100ddba1f180dc55a0bf74285098554438 (diff) | |
| parent | 15db4186b76a95adad15428d391fe7726112ea03 (diff) | |
| download | rust-181bf05d86d906e5a8eea51f8fd702deb7a706cc.tar.gz rust-181bf05d86d906e5a8eea51f8fd702deb7a706cc.zip | |
Rollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez
Add a clickable link to the layout section The layout section (activated by `--show-type-layout`) is currently not linkable to (outside of chrome's link to text feature). This PR makes it linkable via `#layout`.
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 6 | ||||
| -rw-r--r-- | src/test/rustdoc/type-layout.rs | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 4170c73b246..52a2effca0f 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1485,6 +1485,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> { map.insert("synthetic-implementations-list".into(), 1); map.insert("blanket-implementations-list".into(), 1); map.insert("deref-methods".into(), 1); + map.insert("layout".into(), 1); map } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index dcd2eaac7ea..69d66693f75 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1880,7 +1880,11 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) { return; } - writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>"); + writeln!( + w, + "<h2 id=\"layout\" class=\"small-section-header\"> \ + Layout<a href=\"#layout\" class=\"anchor\"></a></h2>" + ); writeln!(w, "<div class=\"docblock\">"); let tcx = cx.tcx(); diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 4eea9809ac5..e5c6e9dc3f9 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -2,6 +2,7 @@ // @has type_layout/struct.Foo.html 'Size: ' // @has - ' bytes' +// @has - '//*[@id="layout"]/a[@href="#layout"]' '' pub struct Foo { pub a: usize, b: Vec<String>, |
