about summary refs log tree commit diff
path: root/src/librustdoc/html/highlight
AgeCommit message (Collapse)AuthorLines
2023-12-01rustdoc: do not escape quotes in body textMichael Howell-5/+5
Escaping quote marks is only needed in attributes, not text. ```console $ du -hs doc-old/ doc-new/ 670M doc-old/ 669M doc-new/ ```
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-1/+1
2022-10-31rustdoc: rename syntax highlighting CSS class `attribute` to `attr`Michael Howell-5/+5
Link classes use the abbreviation `attr`, so why shouldn't syntax highlighting?
2022-08-20Extend decoration test to detect regressionsGuillaume Gomez-3/+8
2022-08-20Update rustdoc testsGuillaume Gomez-9/+11
2022-08-14Update rustdoc testsGuillaume Gomez-31/+31
2022-08-12Rollup merge of #100409 - jsha:highlight-lighter, r=GuillaumeGomezDylan DPC-15/+15
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-15/+15
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-09rustdoc: simplify highlight.rsJacob Hoffman-Andrews-6/+5
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.
2021-10-25rustdoc: use better highlighting for *const, *mut, and &mutMichael Howell-2/+2
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-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-5/+22
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-08Change handling of spans in scrape examples, add test for highlight decorationsWill Crichton-1/+18
2021-10-06Change serialized format to use DefPathHash instead of custom StringWill Crichton-1/+1
Move test to rustdoc-ui Fix test writing to wrong directory Formatting Fix test Add FIXME Remove raw multiline strings
2021-10-06Move highlighting logic from JS to RustWill Crichton-3/+3
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-4/+4
It was marking them up as `<span class="op">=</span><span class="op">&gt;</span>`, which is bloaty and wrong.
2021-08-06Add test for union keyword highlightingGuillaume Gomez-0/+26
2021-08-05Fix invalid generation of HTML in highlightGuillaume Gomez-0/+18
2021-08-05Move extra arguments for highlight URL generation into a new ContextInfo ↵Guillaume Gomez-2/+2
struct for better readability
2021-08-05Update rustdoc testsGuillaume Gomez-3/+3
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-3/+3
2021-05-05Update highlight testsGuillaume Gomez-11/+16
2021-04-08Add test for idents mergeGuillaume Gomez-0/+20
2021-04-02rustdoc: update macro highlight testsMichael Howell-4/+4
2021-01-30rustdoc tweakingbors-4/+5
* Reuse memory * simplify `next_def_id`, avoid multiple hashing and unnecessary lookups * remove `all_fake_def_ids`, use the global map instead (probably not a good step toward parallelization, though...) * convert `add_deref_target` to iterative implementation * use `ArrayVec` where we know the max number of elements * minor touchups here and there * avoid building temporary vectors that get appended to other vectors At most places I may or may not be doing the compiler's job is this PR.
2020-12-24rustdoc: Highlight edition-specific keywords correctly in code blocks, ↵ThePuzzlemaker-2/+3
accounting for code block edition modifiers This is a squash of these commits: - Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers - Fix unit tests - Revert changes to rustc_span::symbol to prepare for merge of #80272 - Use new Symbol::is_reserved API from #80272 - Remove unused import added by accident when merging
2020-11-15Add test to ensure that no DOS backline (\r\n) doesn't create extra backline ↵Guillaume Gomez-11/+24
in source rendering
2020-08-31Update expect-test to 1.0Aleksey Kladov-1/+1
The only change is that `expect_file` now uses path relative to the current file (same as `include!`). Before, it used paths relative to the workspace root, which makes no sense.
2020-08-27Add expect test for rustdoc html highlightingAleksey Kladov-61/+63
It's a unit-test in a sense that it only checks syntax highlighting. However, the resulting HTML is written to disk and can be easily inspected in the browser. To update the test, run with `--bless` argument or set `UPDATE_EXPEC=1` env var
2020-08-27Remove dependency on StringReader from rustdoc highlighterAleksey Kladov-20/+4
rustc_lexer is the lossless lexer, which is a better fit for approximate syntax highlighting. As a side-effect, we can now syntax-highlight even broken code.
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-1/+1
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-07-14rustdoc: glue tokens before highlightingAndy Russell-0/+82
Fixes #72684. This commit also modifies the signature of `Classifier::new` to avoid copying the source being highlighted.