summary refs log tree commit diff
path: root/src/librustdoc/html/highlight.rs
AgeCommit message (Collapse)AuthorLines
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
2021-10-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-11/+64
Scrape code examples from examples/ directory for Rustdoc Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123 Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525 Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-08Move more scrape-examples logic from JS to rustWill Crichton-1/+1
Fix failing test Add missing backslash Fix padding issue with horizontal scrollbar
2021-10-06Change serialized format to use DefPathHash instead of custom StringWill Crichton-5/+1
Move test to rustdoc-ui Fix test writing to wrong directory Formatting Fix test Add FIXME Remove raw multiline strings
2021-10-06Incorporate jyn's feedbackWill Crichton-1/+5
* Move call location logic from function constructor to rendering * Fix issue with macro spans in scraping examples * Clean up example loading logic Documentation / newtype for DecorationInfo Fix line number display Serialize edition of call site, other small cleanup
2021-10-06Move highlighting logic from JS to RustWill Crichton-11/+64
Continue migrating JS functionality Cleanup Fix compile error Clean up the diff Set toggle font to sans-serif
2021-10-04Make rustdoc not highlight `->` and `=>` as operatorsMichael Howell-2/+21
It was marking them up as `<span class="op">=</span><span class="op">&gt;</span>`, which is bloaty and wrong.
2021-09-29Rollup merge of #87428 - GuillaumeGomez:union-highlighting, r=notriddleEric Huss-5/+65
Fix union keyword highlighting in rustdoc HTML sources I followed this logic: if I find an ident "union", I check if it followed by another ident or not. If it's the case, then I consider this is a keyword because it's declaring a union type. To do so I created a new Iterator which allows to peek the next items without moving the current iterator position. This is part of https://github.com/rust-lang/rust/issues/85016. If the fix makes sense, I'll extend it to other weak keywords (the issue only mentions they exist but https://doc.rust-lang.org/nightly/reference/keywords.html#weak-keywords only talks about `dyn` and `'static` so not sure if there is anything else to be done?). cc `@notriddle` (you're one of the last ones who worked on this part of rustdoc so here you go :wink: ) r? `@jyn514`
2021-09-13Add support for primitives in "jump to definition" featureGuillaume Gomez-0/+8
2021-08-19[rustdoc] Wrap code blocks in <code> tagJakub Beránek-3/+4
2021-08-06Fix highlighting for union keywordGuillaume Gomez-5/+65
2021-08-05Remove LightSpan and use Span directlyGuillaume Gomez-28/+21
2021-08-05* Rename LightSpan::empty into LightSpan::dummyGuillaume Gomez-22/+18
* Add Classifier::new_light_span to wrap LightSpan::new_in_file constructor
2021-08-05Add missing root_path when generating links using hrefGuillaume Gomez-1/+8
2021-08-05Fix invalid generation of HTML in highlightGuillaume Gomez-41/+42
2021-08-05formattingGuillaume Gomez-16/+12
2021-08-05Use rustdoc Span in LinkFromSrc directlyGuillaume Gomez-2/+1
2021-08-05Move extra arguments for highlight URL generation into a new ContextInfo ↵Guillaume Gomez-31/+39
struct for better readability
2021-08-05Wrap the span_map tuple index into a type called "LightSpan"Guillaume Gomez-27/+10
2021-08-05Improve code readabilityGuillaume Gomez-55/+42
2021-08-05* Rename Span::from_rustc_span to Span::newGuillaume Gomez-1/+1
* Rename Span::wrap to Span::wrap_raw * Improve documentation for Span::wrap_raw
2021-08-05* Rename 'move_span' into 'local_span_to_global_span'Guillaume Gomez-10/+60
* Add documentation on new arguments/functions
2021-08-05Generate links for methods as wellGuillaume Gomez-3/+3
2021-08-05Add links on source types to go to definitionGuillaume Gomez-34/+152