about summary refs log tree commit diff
path: root/src/librustdoc/html/sources.rs
AgeCommit message (Collapse)AuthorLines
2025-09-30Replace `rustc_span::Span` with a stripped down version for librustdoc's ↵Yotam Ofek-1/+6
highlighter
2025-08-15rustdoc-search: search backend with partitioned suffix treeMichael Howell-0/+1
2025-06-20Convert `ilog(10)` to `ilog10()`Chai T. Rex-1/+1
2025-05-20Get rid of unnecessary `BufDisplay` abstractionYotam Ofek-5/+3
2025-05-20Make some fns return `fmt::Result` to get rid of a few `unwrap`sYotam Ofek-8/+7
2025-04-03Update to new rinja version (askama)Guillaume Gomez-1/+1
2025-03-04`librustdoc`: 2024 edition! 🎊Yotam Ofek-1/+1
2025-02-12Nuke `Buffer` abstraction from `librustdoc` 💣Yotam Ofek-8/+10
2025-02-10Move line numbers into the `<code>` directlyGuillaume Gomez-7/+17
2025-01-22rustdoc: use std's (unstable) `fmt::from_fn` instead of open-coding itYotam Ofek-5/+5
2025-01-22rustdoc: pass around decoration info by refYotam Ofek-2/+2
2024-12-03Rename `is_real_and_local` function into `filename_real_and_local`Guillaume Gomez-3/+4
2024-12-03Improve code for FileName retrieval in rustdocGuillaume Gomez-28/+21
2024-12-01Move `SharedContext` out of `Rc`Guillaume Gomez-4/+2
2024-12-01Stop cloning `Context` so muchGuillaume Gomez-2/+2
2024-11-28Fix new clippy lintsGuillaume Gomez-3/+3
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-4/+4
2024-09-25rm higher-ranked lifetimes from `DocVisitor`Lukas Markeffsky-2/+2
This allows the visitor to borrow from the visitees.
2024-09-23Rollup merge of #129545 - notriddle:notriddle/toolbar-v2, r=GuillaumeGomezMichael Goulet-8/+27
rustdoc: redesign toolbar and disclosure widgets Fixes #77899 Fixes #90310 ## Preview | before | after | ------ | ----- | ![image](https://github.com/user-attachments/assets/ebeec185-3a72-481d-921e-a9a885f348d9) | ![image](https://github.com/user-attachments/assets/08735a65-99d1-4523-ab77-ddb164c0a5db) | ![image](https://github.com/user-attachments/assets/ae8e0f24-49cb-445d-b9bd-cec9c57b94e7) | ![image](https://github.com/user-attachments/assets/ba484f94-b031-41fc-b8a8-6cd81be8fb6b) | ![image](https://github.com/user-attachments/assets/8c2cc041-a138-4950-a12e-3d529c8a5339) | ![image](https://github.com/user-attachments/assets/e7f010bd-19e2-4711-85bf-3fd00c3e5647) | ![image](https://github.com/user-attachments/assets/e2b63785-971c-489e-b069-eb85f6a30620) | ![image](https://github.com/user-attachments/assets/b65eea16-d6a3-4aa3-8a27-6ded74009010) | ![image](https://github.com/user-attachments/assets/1c7b0901-a61a-4325-9d01-9d8b14b476aa) | ![image](https://github.com/user-attachments/assets/d4a485db-d9f1-4a62-94bc-a3d125ea6dc1) | N/A | ![image](https://github.com/user-attachments/assets/7add0a2a-7fd7-483d-87ee-51ee45a2fe5d) | ![image](https://github.com/user-attachments/assets/334f50bc-9f8d-42d9-a7df-95058f7cdfd5) | ![image](https://github.com/user-attachments/assets/451fcc22-b034-453c-ae4b-b948fd6bd779) | ![image](https://github.com/user-attachments/assets/132f720c-802a-466d-bd55-c7a4750acdc3) | ![image](https://github.com/user-attachments/assets/177b7921-06c5-467d-87d3-9cdf88c4e50b) https://notriddle.com/rustdoc-html-demo-12/toolbar-v2/std/index.html ## Description This adds labels to the icons and moves them away from the search box. These changes are made together, because they work together, but are based on several complaints: * The [+/-] thing are a Reddit-ism. They don't look like buttons, but look like syntax <https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>, <https://github.com/rust-lang/rust/issues/59851> (some of these are laundry lists with more suggestions, but they all mention [+/-] looking wrong) * The settings, help, and summary buttons are also too hard to recognize <https://lwn.net/Articles/987070/>, <https://github.com/rust-lang/rust/issues/90310>, <https://github.com/rust-lang/rust/issues/14475#issuecomment-274241997>, <https://internals.rust-lang.org/t/improve-rustdoc-design/12758> ("Not all functionality is self-explanatory, for example the [+] button in the top right corner, the theme picker or the settings button.") The toggle-all and toggle-individual buttons both need done at once, since we want them to look like they go together. This changes them from both being [+/-] to both being arrows. CC <https://github.com/rust-lang/rust/pull/113074#issuecomment-1677469680> and ``@jsha`` regarding the use of triangles for disclosure, which is what everyone wanted, but was pending a good toggle-all button. This PR adds a toggle-all button that should work. Settings and Help are also migrated, so that the whole group can benefit from being described using actual words. The breadcrumbs also get redesigned, so that they use less space, by shrinking the parent module path parts. This is done at the same time as the toolbar redesign because it's, effectively, moving space from the toolbar to the breadcrumbs. This is aimed at avoiding any line wrapping at desktop sizes. ## Prior art This style of toolbar, with explicit labels on the buttons, used to be more popular. It's not very common in web browsers nowadays, and for truly universal icons like :arrow_left: I can understand why, but words are great when icons fail. ![image](https://github.com/user-attachments/assets/9a4a0498-232d-4d60-87b9-f601f4515254)
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-10rustdoc: redesign toolbar and disclosure widgetsMichael Howell-8/+27
This adds labels to the icons and moves them away from the search box. These changes are made together, because they work together, but are based on several complaints: * The [+/-] thing are a Reddit-ism. They don't look like buttons, but look like syntax <https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>, <https://github.com/rust-lang/rust/issues/59851> (some of these are laundry lists with more suggestions, but they all mention [+/-] looking wrong) * The settings, help, and summary buttons are also too hard to recognize <https://lwn.net/Articles/987070/>, <https://github.com/rust-lang/rust/issues/90310>, <https://github.com/rust-lang/rust/issues/14475#issuecomment-274241997>, <https://internals.rust-lang.org/t/improve-rustdoc-design/12758> ("Not all functionality is self-explanatory, for example the [+] button in the top right corner, the theme picker or the settings button.") The toggle-all and toggle-individual buttons both need done at once, since we want them to look like they go together. This changes them from both being [+/-] to both being arrows. Settings and Help are also migrated, so that the whole group can benefit from being described using actual words. Additionally, the Help button is only shown on SERPs, not all the time. This is done for two major reasons: * Most of what's in there is search-related. The things that aren't are keyboard commands, and the search box tells you about that anyway. Pressing <kbd>?</kbd> will temporarily show the button and its popover. * I'm trading it off by showing the help button, even on mobile. It's useful since you can use the search engine suggestions there. * The three buttons were causing line wrapping on too many desktop layouts.
2024-09-07Generate scraped examples buttons in JSGuillaume Gomez-1/+0
2024-09-05Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notriddleMatthias Krüger-19/+38
Unify scraped examples with other code examples Fixes #129763. This first PR both fixes #129763 but also unifies buttons display for code examples: ![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8) You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html). I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer). cc ```@willcrichton``` r? ```@notriddle```
2024-08-31Unify scraped examples with other code examplesGuillaume Gomez-19/+38
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-16/+13
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-23Replace askama with rinjaGuillaume Gomez-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-11-15Re-format code with new rustfmtMark Rousskov-2/+6
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-2/+1
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-17[RFC 3127 - Trim Paths]: Fix building tools (rustdoc, clippy, ...)Urgau-1/+2
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+3
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-1/+1
2023-08-16Use more named format argsGuillaume Gomez-2/+2
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-2/+1
2023-07-14rustdoc: use `src` consistently over `source` in codeMichael Howell-1/+1
The CSS uses an inconsistent mix of both. This commit switches it to always use `src`.
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-03rustdoc: migrate document functions to return a DisplayMichael Howell-3/+3
2023-03-23Rollup merge of #109187 - clubby789:askama-source, r=GuillaumeGomezDylan DPC-31/+27
Render source page layout with Askama ~~I was looking at making `code_html` render into the buffer instead of in advance, but it turned out to need a pretty big refactor, so starting with rearranging the high-level layout.~~ Found another approach which required much less changes cc #108868
2023-03-16clean up few allocklensy-1/+1
2023-03-16Render source page layout with Askamaclubby789-31/+27
Co-authored-by: Michael Howell <michael@notriddle.com>
2023-01-30rustdoc: remove meta keywords from HTMLMichael Howell-2/+1
Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-06Correctly render sidebar for relative module pathsclubby789-16/+44
2022-12-10Clean up lifetimes in rustdoc syntax highlightingNilstrieb-1/+1
Removes a few lifetimes and renames some.
2022-11-19rustdoc: use real buttons for scrape examples controlsMichael Howell-2/+5
2022-11-12rustdoc: avoid excessive HTML generated in example sourcesMichael Howell-5/+5
2022-10-31rustdoc: change `.src-line-numbers > span` to `.src-line-numbers > a`Michael Howell-10/+11
This allows people to treat them like real links, such as right-click to copy URL, and makes the line numbers in a scraped example work at all, when before this commit was added, they had the clickable pointer cursor but did not actually do anything when clicked.
2022-10-29Fix z-indexes of code example feature and cleanup its CSSGuillaume Gomez-2/+7
2022-09-26rustdoc: give `.line-number` / `.line-numbers` meaningful namesMichael Howell-1/+1
2022-09-15rustdoc: use more precise URLs for jump-to-definition linksMichael Howell-1/+4
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