summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
AgeCommit message (Collapse)AuthorLines
2023-06-23Rollup merge of #112927 - GuillaumeGomez:where-clause-indent, r=notriddleMatthias Krüger-2/+2
Fix indentation for where clause in rustdoc pages Screenshot of the bug: ![image](https://github.com/rust-lang/rust/assets/3050060/090cfeaa-0edc-46c7-9ea0-e26ac865b2c2) I used this opportunity to clarify the code a bit because some weird things were going on. r? ````@notriddle````
2023-06-22Fix indentation for where clause in rustdoc pagesGuillaume Gomez-2/+2
2023-06-22Rollup merge of #112906 - ↵Matthias Krüger-1/+2
fmease:rustdoc-render-assoc-ty-body-before-where-clause, r=notriddle rustdoc: render the body of associated types before the where-clause Fixes #112903.
2023-06-21rustdoc: render the assoc ty body before the where-clauseLeón Orell Valerian Liehr-1/+2
2023-06-21Fix union fields displayGuillaume Gomez-3/+2
2023-06-13Fix URL encoding of % sign in Rust Doc.TumoiYorozu-2/+0
2023-06-12Revert "List matching impls on type aliases"Guillaume Gomez-78/+12
This reverts commit 4b1d13d9841c815915433ca2a3088a8e3e97ad96.
2023-06-09List matching impls on type aliasesGuillaume Gomez-12/+78
2023-06-05Rollup merge of #112243 - GuillaumeGomez:rm-unneeded-buffer-creations, ↵Guillaume Gomez-3/+3
r=notriddle Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directly With the recent changes, `wrap_item` can now directly take `&mut Write`, which makes some `Buffer` creations unneeded. r? `@notriddle`
2023-06-05Move write! arguments directly into the stringGuillaume Gomez-2/+2
2023-06-05Auto merge of #110945 - wackbyte:doc-vis-on-inherent-assoc-types, r=jshabors-1/+3
rustdoc: render visibility on associated types This should only affect inherent associated types (#8995).
2023-06-03Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directlyGuillaume Gomez-2/+2
2023-05-30rustdoc: simplify `clean` by removing `FnRetTy`Michael Howell-1/+6
The default fn ret ty is always unit. Just use that. Looking back at the time when `FnRetTy` (then called `FunctionRetTy`) was first added to rustdoc, it seems to originally be there because `-> !` was a special form: the never type didn't exist back then. https://github.com/rust-lang/rust/commit/eb01b17b06eb35542bb80ff7456043b0ed5572ba#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-4/+5
2023-05-17Add missing backslash in HTML stringGuillaume Gomez-1/+1
2023-05-04IAT: Rustdoc integrationLeón Orell Valerian Liehr-1/+3
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+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-30Rollup merge of #110983 - GuillaumeGomez:foreign-repr, r=notriddleMatthias Krüger-30/+8
rustdoc: Get `repr` information through `AdtDef` for foreign items As suggested by `@notriddle,` this approach works too. The only downside is that the display of the original attribute isn't kept, but I think it's an acceptable downside. r? `@notriddle`
2023-04-29Unify attributes retrieval for JSON and HTML renderingGuillaume Gomez-73/+2
2023-04-29Get `repr` information through `AdtDef` for foreign itemsGuillaume Gomez-10/+59
2023-04-28rustdoc: fix weird margins between Deref impl itemsMichael Howell-6/+12
In the old setup, if the dereffed-to item has multiple impl blocks, each one gets its own `div.impl-items` in the section, but there are no headers separating them. Since the last method in a `div.impl-items` has no bottom margin, and there are no margins between these divs, there is no margin between the last method of one impl and the first method of the following impl. This patch fixes it by simplifying the HTML. Each Deref block gets exactly one `div.impl-items`, no matter how many impl blocks it actually has.
2023-04-28rustdoc: render visibility on associated typeswackbyte-1/+3
This should only affect inherent associated types.
2023-04-22Rollup merge of #109949 - notriddle:notriddle/type-layout, r=jshaYuki Okushi-0/+1
rustdoc: migrate `document_type_layout` to askama
2023-04-21rustdoc: factor `document_type_layout` into its own moduleMichael Howell-0/+1
2023-04-12remove some unneeded importsKaDiWa-1/+0
2023-04-05rustdoc: migrate `item_union` to an Askama templateMichael Howell-35/+42
2023-04-03rustdoc: migrate document functions to return a DisplayMichael Howell-124/+140
2023-04-03rustdoc: convert render_attributes_in_pre to return a DisplayMichael Howell-5/+12
2023-03-22Rollup merge of #108954 - notriddle:notriddle/notable-trait-generic, r=camelidMatthias Krüger-2/+2
rustdoc: handle generics better when matching notable traits This commit makes the `clean::Type::is_same` non-commutative (renaming it `is_doc_subtype_of`), so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value. Fixes #100322 Fixes #55082 Preview: * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.new * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.from-12 * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/iter/trait.Iterator.html#method.intersperse_with * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/string/struct.String.html#method.as_bytes
2023-03-12rustdoc: rename `Type::is_same` to `is_doc_subtype_of`Michael Howell-2/+2
2023-03-11Rollup merge of #108784 - clubby789:askama-sidebar, r=jsha,GuillaumeGomezMatthias Krüger-632/+1
rustdoc: Migrate sidebar rendering to Askama cc #108757 Renders the sidebar for documentation using an Askama template
2023-03-11Rollup merge of #108757 - clubby789:askama-move, r=notriddle,jsha,GuillaumeGomezMatthias Krüger-43/+54
rustdoc: Migrate `document_item_info` to Askama https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/rustdoc.20allocations.20are.20slow Hoping to piece-by-piece migrate things to template. Had a few failed attempts at more complex parts of the code, so this is just a start.
2023-03-11Rollup merge of #107629 - pitaj:rustdoc-search-deprecated, r=jshaMatthias Krüger-0/+1
rustdoc: sort deprecated items lower in search closes #98759 ### Screenshots `i32::MAX` show sup above `std::i32::MAX` and `core::i32::MAX` ![image](https://user-images.githubusercontent.com/803701/216725619-40afb7b0-e984-4a2e-ab5b-a95b24736b0e.png) If just searching for `min`, the deprecated results show up far below other things: ![image](https://user-images.githubusercontent.com/803701/216725672-e4325d37-9bfe-47eb-a1fe-0e57092aa811.png) one page later ![image](https://user-images.githubusercontent.com/803701/216725932-cd1c4a42-d527-44fb-a4ab-5a6d243659cc.png) ~~And, as you can see, the "Deprecation planned" message shows up in the search results. The same is true for fully-deprecated items like `mem::uninitialized`: ![image](https://user-images.githubusercontent.com/803701/216726268-1657e77a-563f-45a0-85a7-3a0cf4d66d6f.png)~~ Edit: the deprecation message change was removed from this PR. Only the sorting is changed.
2023-03-10Render doc sidebar using Askamaclubby789-632/+1
2023-03-10Migrate `document_item_info` to templatesclubby789-43/+54
2023-03-10rustdoc: sort deprecated items lower in searchPeter Jaszkowiak-0/+1
serialize `q` (`itemPaths`) sparsely overall 4% reduction in search index size
2023-03-09rustdoc: handle generics better when matching notable traitsMichael Howell-2/+2
This commit makes the `clean::Type::is_same` non-commutative, so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value.
2023-02-15Use more let chainGuillaume Gomez-27/+25
2023-02-13Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, ↵Matthias Krüger-1/+1
r=GuillaumeGomez rustdoc: merge doctest tooltip with notable traits tooltip Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 <details><summary>a user report where the tooltip arrow overlaps the text</summary> ![](https://cdn.discordapp.com/attachments/443150878111694848/1066420139530145812/this-example-is-not-tested-busted-rendering.png) </details> Fixes #91100 Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing> Screenshot: ![image](https://user-images.githubusercontent.com/1593513/214975516-72667632-4609-49fa-8c37-e8d2ba1ba7dc.png)
2023-02-11Rollup merge of #107490 - notriddle:notriddle/rm-sidebar-tooltip, ↵Dylan DPC-3/+0
r=GuillaumeGomez rustdoc: remove inconsistently-present sidebar tooltips Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-02-03rustdoc: use the same URL escape rules for fragments as for examplesMichael Howell-23/+52
2023-01-31rustdoc: remove inconsistently-present sidebar tooltipsMichael Howell-3/+0
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-30rustdoc: remove meta keywords from HTMLMichael Howell-2/+0
Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-28rustdoc: remove unused class `has-srclink`Michael Howell-16/+4
Stopped being used in CSS with 73d0f7c7b68784f1db0a1f53855c20d118a7e8b0
2023-01-27rustdoc: merge doctest tooltip with notable traits tooltipMichael Howell-1/+1
Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 Fixes #91100
2023-01-22rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)`Vadim Petrochenkov-6/+6
Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept.
2023-01-16Move compiler input and ouput paths into sessionOli Scherer-1/+1
2023-01-14Rollup merge of #106855 - klensy:rd-s, r=notriddleMatthias Krüger-3/+3
rustdoc: few small cleanups
2023-01-14Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, ↵Matthias Krüger-1/+1
r=GuillaumeGomez rustdoc: remove `docblock` class from notable trait popover This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974
2023-01-14Rollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomezYuki Okushi-2/+2
rustdoc: remove unnecessary DOM class `h1.fqn` It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.