about summary refs log tree commit diff
path: root/src/librustdoc/html/highlight.rs
AgeCommit message (Collapse)AuthorLines
2023-12-01rustdoc: do not escape quotes in body textMichael Howell-3/+9
Escaping quote marks is only needed in attributes, not text. ```console $ du -hs doc-old/ doc-new/ 670M doc-old/ 669M doc-new/ ```
2023-11-15Re-format code with new rustfmtMark Rousskov-11/+24
2023-09-15Implement custom classes for rustdoc code blocks with ↵Guillaume Gomez-4/+21
`custom_code_classes_in_docs` feature
2023-08-16Use more named format argsGuillaume Gomez-4/+8
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-11/+10
2023-07-13Rollup merge of #113623 - GuillaumeGomez:add-jump-to-doc, r=notriddleMatthias Krüger-0/+5
Add jump to doc I'm using the source code pages of the compiler quite a lot, but one thing missing is the possibility to jump back from the source code to the item documentation. Since I also got a few others complaining about it, I think it's fine to add it since this option is nightly only. This PR adds a link to jump back to item's documentation on the item definition (so on `Bar` in `struct Bar {... }`, as described in the unofficial [RFC](https://github.com/GuillaumeGomez/rfcs/blob/rustdoc-jump-to-definition/text/000-rustdoc-jump-to-definition.md)). r? ````@notriddle````
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-4/+2
2023-07-12Add jump to docGuillaume Gomez-0/+5
2023-05-02initial step towards implementing C string literalsDeadbeef-1/+3
2023-04-16Spelling librustdocJosh Soref-5/+5
* associated * collected * correspondence * inlining * into * javascript * multiline * variadic Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-01a couple clippy::complexity fixesMatthias Krüger-2/+2
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-16Render source page layout with Askamaclubby789-38/+21
Co-authored-by: Michael Howell <michael@notriddle.com>
2023-02-15Use more let chainGuillaume Gomez-4/+2
2023-02-13Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, ↵Matthias Krüger-5/+11
r=GuillaumeGomez rustdoc: merge doctest tooltip with notable traits tooltip Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 <details><summary>a user report where the tooltip arrow overlaps the text</summary> ![](https://cdn.discordapp.com/attachments/443150878111694848/1066420139530145812/this-example-is-not-tested-busted-rendering.png) </details> Fixes #91100 Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing> Screenshot: ![image](https://user-images.githubusercontent.com/1593513/214975516-72667632-4609-49fa-8c37-e8d2ba1ba7dc.png)
2023-01-30rustdoc: remove unnecessary wrapper div.item-decl from HTMLMichael Howell-4/+4
2023-01-27rustdoc: merge doctest tooltip with notable traits tooltipMichael Howell-5/+11
Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 Fixes #91100
2022-12-10Clean up lifetimes in rustdoc syntax highlightingNilstrieb-23/+23
Removes a few lifetimes and renames some.
2022-10-31rustdoc: rename syntax highlighting CSS class `attribute` to `attr`Michael Howell-1/+1
Link classes use the abbreviation `attr`, so why shouldn't syntax highlighting?
2022-10-29Fix z-indexes of code example feature and cleanup its CSSGuillaume Gomez-0/+4
2022-10-08Clean up rustdoc highlight.rs imports a bitGuillaume Gomez-4/+2
2022-09-28Address review comments.Nicholas Nethercote-1/+1
2022-09-26Add `rustc_lexer::TokenKind::Eof`.Nicholas Nethercote-1/+5
For alignment with `rust_ast::TokenKind::Eof`. Plus it's a bit faster, due to less `Option` manipulation in `StringReader::next_token`.
2022-09-26Make `rustc_lexer::cursor::Cursor` public.Nicholas Nethercote-5/+4
`Cursor` is currently hidden, and the main tokenization path uses `rustc_lexer::first_token` which involves constructing a new `Cursor` for every single token, which is weird. Also, `first_token` also can't handle empty input, so callers have to check for that first. This commit makes `Cursor` public, so `StringReader` can contain a `Cursor`, which results in a simpler structure. The commit also changes `StringReader::advance_token` so it returns an `Option<Token>`, simplifying the the empty input case.
2022-09-15rustdoc: use more precise URLs for jump-to-definition linksMichael Howell-3/+5
As an example, this cuts down <https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/ty/mod.rs.html> by about 11%. $ du -h new_mod.rs.html old_mod.rs.html 296K new_mod.rs.html 332K old_mod.rs.html
2022-09-10Simplify DOM for codeblocks tooltipsGuillaume Gomez-13/+14
2022-09-09rustdoc: simplify the codeblock tooltipMichael Howell-27/+28
This commit moves the tooltip into example-wrap, simplifying allowing several overly-complex things to be fixed: * The mousover javascript can be removed, because hovering example-wrap can style the tooltip inside. * The sibling selecor can be removed, because hovering the tooltip also hovers the wrapper, which can hover the codeblock itself. * The relative positioning of the `<li>` tag, which was added in e861efd9f9ca45c1048a256812dfe8faffbb1367 to fix the positioning of the code tooltip, can now be removed, because example-wrap itself already has relative positioning.
2022-08-31Fix a bunch of typoDezhi Wu-2/+2
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-20Clean up highlight `<span>` merge codeGuillaume Gomez-121/+118
2022-08-20Merge "EnterSpan" events to reduce code blocks DOM sizeGuillaume Gomez-23/+68
2022-08-19Fix invalid comparison for Class::Decoration in `is_equal_to`Guillaume Gomez-2/+2
2022-08-14Don't generate ident elements as DOM nodesGuillaume Gomez-7/+20
2022-08-14Merge HTML elements in highlighting when they can be merged togetherGuillaume Gomez-8/+155
2022-08-12Rollup merge of #100409 - jsha:highlight-lighter, r=GuillaumeGomezDylan DPC-10/+7
rustdoc: don't generate DOM element for operator In our source page highlighting, we were generating `<span class="op">` tags for all "operators", including e.g. `<` `>` around generic parameters, `*`, `&`. This contributed significantly to DOM size, but we don't actually style `.op` except in the ayu theme. Remove the styles for `.op` in ayu, and stop generating the `<span>`s. This reduces DOM size of an example page[1] from 265,938 HTML elements to 242,165 elements, a 9% reduction. r? ``@GuillaumeGomez`` Demo: (warning - slow!) https://rustdoc.crud.net/jsha/highlight-lighter/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html [1]: https://doc.rust-lang.org/nightly/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html
2022-08-11rustdoc: don't generate DOM element for operatorJacob Hoffman-Andrews-10/+7
In our source page highlighting, we were generating `<span class="op">` tags for all "operators", including e.g. `<` `>` around generic parameters, `*`, `&`. This contributed significantly to DOM size, but we don't actually style `.op` except in the ayu theme. Remove the styles for `.op` in ayu, and stop generating the `<span>`s. This reduces DOM size of an example page[1] from 265,938 HTML elements to 242,165 elements, a 9% reduction. [1]: https://doc.rust-lang.org/nightly/src/core/up/up/stdarch/crates/core_arch/src/x86/avx512f.rs.html
2022-08-11Rollup merge of #99337 - jsha:simplify-highlight, r=GuillaumeGomezMatthias Krüger-33/+55
rustdoc: simplify highlight.rs Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code. I've tested a build of std docs before and after, and this does not change the generated HTML at all. Followup from https://github.com/rust-lang/rust/pull/91264#discussion_r901151101 r? ```@GuillaumeGomez```
2022-08-09rustdoc: simplify highlight.rsJacob Hoffman-Andrews-33/+55
Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code.
2022-08-01Shrink `Token`.Nicholas Nethercote-1/+1
From 72 bytes to 12 bytes (on x86-64). There are two parts to this: - Changing various source code offsets from 64-bit to 32-bit. This is not a problem because the rest of rustc also uses 32-bit source code offsets. This means `Token` is no longer `Copy` but this causes no problems. - Removing the `RawStrError` from `LiteralKind`. Raw string literal invalidity is now indicated by a `None` value within `RawStr`/`RawByteStr`, and the new `validate_raw_str` function can be used to re-lex an invalid raw string literal to get the `RawStrError`. There is one very small change in behaviour. Previously, if a raw string literal matched both the `InvalidStarter` and `TooManyHashes` cases, the latter would override the former. This has now changed, because `raw_double_quoted_string` now uses `?` and so returns immediately upon detecting the `InvalidStarter` case. I think this is a slight improvement to report the earlier-detected error, and it explains the change in the `test_too_many_hashes` test. The commit also removes a couple of comments that refer to #77629 and say that the size of these types don't affect performance. These comments are wrong, though the performance effect is small.
2022-06-20Integrate `generate_macro_def_id_path` into `href_with_root_path`Guillaume Gomez-67/+2
2022-06-20Improve code readability and documentationGuillaume Gomez-26/+54
2022-06-20Rename ContextInfo into HrefContextGuillaume Gomez-25/+25
2022-06-20Add support for macro in "jump to def" featureGuillaume Gomez-19/+107
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-6/+6
2022-03-04librustdoc: adopt let else in more placesest31-10/+6
2022-02-03rustdoc: clippy::complexity fixesMatthias Krüger-2/+1
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2021-12-28remove in_band_lifetimes from librustdocMichael Goulet-3/+3
2021-11-23Fix RustDocEsteban Kuber-1/+1
2021-11-04Sort scraped call locations before serializingWill Crichton-1/+7
2021-10-27Rollup merge of #90278 - notriddle:notriddle/highlight-ptr, ↵Matthias Krüger-6/+21
r=jyn541,GuillaumeGomez rustdoc: use better highlighting for *const, *mut, and &mut This generates more consistent HTML for these RefKeyWord combinations. Before: ![image](https://user-images.githubusercontent.com/1593513/138742752-7e00a3f7-4621-4c62-82d1-3e4c2ef503d1.png) After: ![image](https://user-images.githubusercontent.com/1593513/138743955-90abcdcd-fc88-4e2f-95bb-c1b1635c0001.png)
2021-10-25rustdoc: use better highlighting for *const, *mut, and &mutMichael Howell-6/+21
This generates more consistent HTML for these RefKeyWord combinations. Before: ![image](https://user-images.githubusercontent.com/1593513/138742752-7e00a3f7-4621-4c62-82d1-3e4c2ef503d1.png) After: ![image](https://user-images.githubusercontent.com/1593513/138743955-90abcdcd-fc88-4e2f-95bb-c1b1635c0001.png)
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-2/+2