about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
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
2025-03-04`librustdoc`: 2024 edition! 🎊Yotam Ofek-3/+3
2025-02-23return `impl fmt::Display` in more places instead of writing to stringsYotam Ofek-715/+751
2025-02-14librustdoc: lazily format "read more" link in `document_short`Yotam Ofek-6/+15
2025-02-14librustdoc: lazily format list of aliases in `render_impl_summary`Yotam Ofek-6/+6
2025-02-14librustdoc: make `notable_traits_button` formatting lazyYotam Ofek-11/+14
2025-02-14librustdoc: make `assoc_href_attr` formatting lazyYotam Ofek-11/+33
2025-02-12Nuke `Buffer` abstraction from `librustdoc` 💣Yotam Ofek-159/+207
2025-01-30fix(rustdoc): always use a channel when linking to doc.rust-lang.orgAlexis (Poliorcetics) Bourget-2/+2
2025-01-22rustdoc: use std's (unstable) `fmt::from_fn` instead of open-coding itYotam Ofek-15/+14
2025-01-22rustdoc: pass around decoration info by refYotam Ofek-1/+1
2024-12-25Improve rustdoc codeGuillaume Gomez-1/+1
2024-12-20Rollup merge of #134321 - dtolnay:docassocconst, r=fmeaseJacob Pratt-21/+53
Hide `= _` as associated constant value inside impl blocks Closes #134320. ### Before: <img src="https://github.com/user-attachments/assets/19d28811-45d2-4563-9726-f40c6af411c6" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/1ecf8764-97ce-47f0-87fa-3b174d2fc578" width="300"> ### After: <img src="https://github.com/user-attachments/assets/6408c4ca-b1c4-42e4-884b-248833a4865f" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/df2f6981-16f6-409f-8abb-73c0a4a71d6b" width="300"> r? `@fmease`
2024-12-19Rename TyMethodItem -> RequiredMethodItemDavid Tolnay-4/+4
2024-12-19Rename TyAssocTypeItem -> RequiredAssocTypeItemDavid Tolnay-3/+3
2024-12-19Suppress `= _` on associated constants in implsDavid Tolnay-10/+40
2024-12-19Split AssocConstItem into ProvidedAssocConstItem and ImplAssocConstItemDavid Tolnay-3/+5
2024-12-19Rename TyAssocConstItem -> RequiredAssocConstItemDavid Tolnay-3/+3
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-2/+3
2024-12-05Turn `markdown_split_summary_and_content` into a method of `Markdown`Guillaume Gomez-3/+3
2024-12-05Always display first line of impl blocks even when collapsedGuillaume Gomez-17/+28
2024-12-01Move `SharedContext` out of `Rc`Guillaume Gomez-36/+34
2024-11-28Fix new clippy lintsGuillaume Gomez-12/+10
2024-11-12Rollup merge of #132541 - RalfJung:const-stable-extern-crate, r=compiler-errorsMatthias Krüger-3/+1
Proper support for cross-crate recursive const stability checks ~~Stacked on top of https://github.com/rust-lang/rust/pull/132492; only the last three commits are new.~~ In a crate without `staged_api` but with `-Zforce-unstable-if-unmarked`, we now subject all functions marked with `#[rustc_const_stable_indirect]` to recursive const stability checks. We require an opt-in so that by default, a crate can be built with `-Zforce-unstable-if-unmarked` and use nightly features as usual. This property is recorded in the crate metadata so when a `staged_api` crate calls such a function, it sees the `#[rustc_const_stable_indirect]` and allows it to be exposed on stable. This, finally, will let us expose `const fn` from hashbrown on stable. The second commit makes const stability more like regular stability: via `check_missing_const_stability`, we ensure that all publicly reachable functions have a const stability attribute -- both in `staged_api` crates and `-Zforce-unstable-if-unmarked` crates. To achieve this, we move around the stability computation so that const stability is computed after regular stability is done. This lets us access the final result of the regular stability computation, which we use so that `const fn` can inherit the regular stability (but only if that is "unstable"). Fortunately, this lets us get rid of an `Option` in `ConstStability`. This is the last PR that I have planned in this series. r? `@compiler-errors`
2024-11-10ensure that all publicly reachable const fn have const stability infoRalf Jung-3/+1
2024-10-30rustdoc-search: add type param names to indexMichael Howell-0/+1
2024-10-25Re-do recursive const stability checksRalf Jung-1/+3
Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-10-23rustdoc: adjust spacing and typography in headerMichael Howell-2/+2
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-19/+19
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-9/+9
2024-09-19Auto merge of #130069 - GuillaumeGomez:gen-scraped-buttons, r=notriddlebors-1/+0
Generate scraped examples buttons in JS Follow-up of https://github.com/rust-lang/rust/pull/129796. To reduce the page size when there are scraped examples, we can generate their buttons in JS since they require JS to work in any case. There should be no changes in display or in functionality. You can test it [here](https://rustdoc.crud.net/imperio/gen-scraped-buttons/doc/scrape_examples/fn.test.html). cc `@willcrichton` r? `@notriddle`
2024-09-10Auto merge of #129337 - EtomicBomb:rfc, r=notriddlebors-0/+1
rustdoc rfc#3662 changes under unstable flags * All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * `tests/rustdoc/` tests for the new flags
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-11/+11
2024-09-07rfc#3662 changes under unstable flagsEtomicBomb-0/+1
* All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * update tests/run-make/rustdoc-default-output/rmake.rs golden
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-24/+9
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-09-05Make impl associated constants sorted firstGuillaume Gomez-11/+11
2024-09-05Sort impl associated items by kinds and then by appearanceGuillaume Gomez-1/+52
2024-09-02Rollup merge of #127474 - tesuji:foldable-inline-derefs, r=t-rustdocMatthias Krüger-4/+13
doc: Make block of inline Deref methods foldable After: ![image](https://github.com/rust-lang/rust/assets/15225902/3e8ab320-dbf7-436f-9be0-d0ef82664663) Before: ![image](https://github.com/rust-lang/rust/assets/15225902/f6f7635d-d4c3-437e-a2d9-147726287b05) Fix #127470. Current status: - [x] Bug when hovering over title "Methods from ...": The anchor sign $ overlaps with `[-]`: https://github.com/rust-lang/rust/pull/127474#issuecomment-2222930038 => Fixed by https://github.com/rust-lang/rust/pull/127474#issuecomment-2228886292
2024-08-31Unify scraped examples with other code examplesGuillaume Gomez-24/+9
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-08-25Generate missing source link on impl associated typesGuillaume Gomez-0/+2
2024-08-20Auto merge of #128252 - EtomicBomb:pre-rfc, r=notriddlebors-0/+2
modularize rustdoc's write_shared Refactor src/librustdoc/html/render/write_shared.rs to reduce code duplication, adding unit tests * Extract + unit test code for sorting and rendering JSON, which is duplicated 9 times in the current impl * Extract + unit test code for encoding JSON as single quoted strings, which is duplicated twice in the current impl * Unit tests for cross-crate information file formats * Generic interface to add new kinds of cross-crate information files in the future * Intended to match current behavior exactly, except for a merge info comment it adds to the bottom of cci files * This PR is intended to reduce the review burden from my [mergeable rustdoc rfc](https://github.com/rust-lang/rfcs/pull/3662) implementation PR, which is a [small commit based on this branch](https://github.com/EtomicBomb/rust/tree/rfc). This code is agnostic to the RFC and does not include any of the flags discussed there, but cleanly enables the addition of these flags in the future because it is more modular
2024-08-10Stop showing impl items for negative implsGuillaume Gomez-16/+21