rust/src/librustdoc
Matthias Krüger cad609d9e3
Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddle
[rustdoc] Allows links in headings

Reopening of https://github.com/rust-lang/rust/pull/94360.

# Explanations

Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this:

![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3)

<details>
<summary>previous version</summary>

![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee)

</details>

Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it.

You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html).

cc `@camelid`
r? `@notriddle`
2024-01-19 19:26:59 +01:00
..
clean Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasper 2024-01-18 20:56:20 +01:00
doctest pass unused_extern_crates in librustdoc::doctest::make_test 2023-04-25 17:20:58 +03:00
formats rustdoc: Move AssocItemRender and RenderMode to html::render. 2023-11-29 00:56:47 +00:00
html Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddle 2024-01-19 19:26:59 +01:00
json Introduce const Trait (always-const trait bounds) 2023-12-27 12:51:32 +01:00
passes Make crate_inherent_impls fallible and stop using track_errors for it 2024-01-17 10:02:29 +00:00
theme rustdoc: merge theme css into rustdoc.css 2023-09-15 07:40:17 -07:00
askama.toml Remove unneeded minus sign in jinja tags 2023-03-06 11:38:15 +01:00
Cargo.toml Update itertools to 0.11. 2023-11-22 08:13:21 +11:00
config.rs Rename consuming chaining methods on DiagnosticBuilder. 2024-01-10 07:40:00 +11:00
core.rs Rename consuming chaining methods on DiagnosticBuilder. 2024-01-10 07:40:00 +11:00
docfs.rs remove redundant imports 2023-12-10 10:56:22 +08:00
doctest.rs Stop using DiagnosticBuilder::buffer in the parser. 2024-01-11 18:37:56 +11:00
error.rs Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
externalfiles.rs Shorten some error invocations. 2024-01-10 07:33:06 +11:00
fold.rs rustdoc: bind typedef inner type items to the folding system 2023-08-26 00:15:02 +02:00
lib.rs Shorten some error invocations. 2024-01-10 07:33:06 +11:00
lint.rs fix some typos found scrolling through the docs 2023-12-22 18:28:19 -05:00
markdown.rs Minimize pub usage in source_map.rs. 2023-11-02 19:35:00 +11:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
scrape_examples.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
theme.rs Shorten some error invocations. 2024-01-10 07:33:06 +11:00
visit.rs rustdoc: Rename clean items from typedef to type alias 2023-08-21 13:56:22 -07:00
visit_ast.rs Rename Session::span_diagnostic as Session::dcx. 2023-12-18 16:06:21 +11:00
visit_lib.rs Correctly handle --document-hidden-items 2023-07-14 17:25:09 +02:00

For more information about how librustdoc works, see the rustc dev guide.