about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-09-26Rollup merge of #147047 - notriddle:toolbar-index, r=GuillaumeGomezMatthias Krüger-1/+6
rustdoc: put the toolbar on the all item index
2025-09-25rustdoc: put the toolbar on the all item indexMichael Howell-1/+6
2025-09-25Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, ↵Matthias Krüger-38/+142
r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR https://github.com/rust-lang/rust/pull/146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
2025-09-25rustdoc: hide `#[repr(...)]` if it isn't part of the public ABILeón Orell Valerian Liehr-21/+61
2025-09-25rustdoc: Fully escape link section and export nameLeón Orell Valerian Liehr-2/+2
Escape "special characters" (e.g., double quotes `"` and line breaks `\n`). Escape HTML. Lastly, add regression tests and clean up existing tests.
2025-09-25rustdoc: Slightly clean up attr renderingLeón Orell Valerian Liehr-93/+52
2025-09-17Remove ImplSubjectCameron Steffen-5/+5
2025-09-14rustdoc: Move HTML-specific attr rendering code into HTML rendering modLeón Orell Valerian Liehr-38/+143
These functions used to be shared with the JSON backend but nowadays they aren't.
2025-09-02squash fix `render_call_locations` panic when default span points at file ↵Janis-15/+37
outside of local_sources add test against crashing with --html-after-content file correctly add --html-after-content to env not args formatting fix for rustdoc-call-locations-after-content/rmake.rs Use local crate source file as default span in `render_call_locations` - avoids unwrapping the first file added to the source map as a local file in `href_from_span` move test to tests/rustdoc-gui, rename to scrape_examples_ice test link is correct use rustdocflags, rename path in example, track lock file factor out duplicate function calls use compile-flags to make sure the after.html file is actually included in the rustdoc call fix goml go-to path increment assert-count in sidebar-source-code.goml adjust crate-search width in search-result-display.goml renamed Bar in scrape_examples_ice test make crate name shorter ..
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-0/+5
2025-08-23rustdoc: make attributes render consistentlyKarol Zwolak-18/+19
* make attributes render inside code elements and inside divs with class `code-attribute` * render attributes for macros, associated constants, and struct/union fields
2025-08-15rustdoc-search: search backend with partitioned suffix treeMichael Howell-21/+144
2025-08-14Revert "rustdoc search: prefer stable items in search results"Guillaume Gomez-6/+0
This reverts commit 1140e90074b0cbcfdea8535e4b51877e2838227e.
2025-08-14Revert "rustdoc: IndexItem::{stability -> is_unstable}"Guillaume Gomez-1/+6
This reverts commit 5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76.
2025-08-09Rollup merge of #141658 - lolbinarycat:rustdoc-search-stability-rank-138067, ↵Stuart Cook-0/+1
r=GuillaumeGomez rustdoc search: prefer stable items in search results fixes https://github.com/rust-lang/rust/issues/138067 this does add a new field to the search index, but since we're only listing unstable items instead of adding a boolean flag to every item, it should only increase the search index size of sysroot crates, since those are the only ones using the `staged_api` feature, at least as far as the rust project is concerned.
2025-08-08rustdoc: IndexItem::{stability -> is_unstable}binarycat-8/+2
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-4/+2
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-20/+19
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-1/+1
2025-07-17Improve path segment joining.Nicholas Nethercote-4/+5
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-15rustdoc-json: Structured attributesAlona Enraght-Moony-3/+3
Implements https://www.github.com/rust-lang/rust/issues/141358. This has 2 primary benefits: 1. For rustdoc-json consumers, they no longer need to parse strings of attributes, but it's there in a structured and normalized way. 2. For rustc contributors, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on https://github.com/rust-lang/rust/issues/131229 without needing to bump `FORMAT_VERSION`. (Over time, as the attribute refractor continues, I expect we'll add new things to `rustdoc_json_types::Attribute`. But this can be done separately to the rustc changes).
2025-07-13update issue number for `const_trait_impl`Deadbeef-2/+2
2025-07-03Auto merge of #143363 - jdonszelmann:rollup-7cv1kql, r=jdonszelmannbors-1/+1
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-29Lazy-ify some markdown renderingYotam Ofek-19/+16
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-2/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-10rustdoc search: prefer stable items in search resultsbinarycat-1/+8
fixes https://github.com/rust-lang/rust/issues/138067
2025-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-6/+6
rustdoc: cleanups relating to allocations These commits generally clean up the code a bit and also reduce allocation rates a bit. r? `@camelid`
2025-05-26Avoid some unnecessary cloning.Nicholas Nethercote-6/+6
2025-05-25Update to new APIGuillaume Gomez-1/+1
2025-05-25Improve codeGuillaume Gomez-6/+4
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-1/+21
2025-05-25Split `Item::attributes` method into threeGuillaume Gomez-2/+2
2025-05-20Replace some `unwrap`s with `?`s where possibleYotam Ofek-2/+2
2025-05-20Make some fns return `fmt::Result` to get rid of a few `unwrap`sYotam Ofek-16/+17
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-1/+1
2025-04-24Make impl item info come before docGuillaume Gomez-11/+15
2025-04-17Rollup merge of #139846 - nnethercote:kw-Empty-rustdoc, r=GuillaumeGomezMatthias Krüger-1/+1
Remove `kw::Empty` uses in rustdoc Helps with #137978. r? ``@GuillaumeGomez``
2025-04-15Avoid using `kw::Empty` for param names in rustdoc.Nicholas Nethercote-1/+1
2025-04-10lazify `render_assoc_items_inner`Yotam Ofek-37/+54
2025-04-10make `doc_impl_item` and `render_default_items` receive `impl fmt::Write`Yotam Ofek-126/+108
2025-04-10make `AllTypes::print` return `impl fmt::Display`Yotam Ofek-29/+34
2025-04-10Rollup merge of #138605 - xizheyin:issue-138567, r=GuillaumeGomezMatthias Krüger-20/+17
Clean up librustdoc::html::render to be better encapsulated Closes #138567
2025-04-09librustdoc: remove IndexItem::new, use previous fields constructorxizheyin-44/+12
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-03Update to new rinja version (askama)Guillaume Gomez-1/+1
2025-03-24Clean up librustdoc::html::render to be better encapsulatedxizheyin-32/+61
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-23Rollup merge of #138574 - lolbinarycat:rustdoc-deref-24686-v2, r=GuillaumeGomezJacob Pratt-2/+14
rustdoc: be more strict about "Methods from Deref" fixes #137083 fixes #24686 Currently done: * [x] fix `render_assoc_items_inner * [x] fix sidebar logic * [x] port test from https://github.com/rust-lang/rust/pull/137564 * [x] add test for sidebar items Note that this does not yet fix the sidebar logic.
2025-03-22rustdoc: be more strict about "Methods from Deref"binarycat-2/+14
hack: is_doc_subtype_of always returns true for TyAlias it's worth noting that this function is only used in the handling of "Methods from Deref", and we were previously assuming all generic parameters were meaningless, so this is still an improvment from the status quo. this change means that we will have strictly less false positives without adding any new false negitives. Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-03-15refactor `notable_traits_button` to use iterator combinators instead of for loopYotam Ofek-21/+11
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-104/+99
Get rid of the `Captures` hack