summary refs log tree commit diff
path: root/src/librustdoc/html/render
AgeCommit message (Collapse)AuthorLines
2022-06-24Rollup merge of #91264 - GuillaumeGomez:macro-jump-to-def, r=jshaYuki Okushi-17/+66
Add macro support in jump to definition feature Fixes #91174. To do so, I check if the span comes from an expansion, and if so, I infer the original macro `DefId` or `Span` depending if it's a defined in the current crate or not. There is one limitation due to macro expansion though: ```rust macro_rules! yolo { () => {}} fn foo() { yolo!(); } ``` In `foo`, `yolo!` won't be linked because after expansion, it is replaced by nothing (which seems logical). So I can't get an item from the `Visitor` from which I could tell if its `Span` comes from an expansion. I added a test for this specific limitation alongside others. Demo: https://rustdoc.crud.net/imperio/macro-jump-to-def/src/foo/check-source-code-urls-to-def-std.rs.html As for the empty macro issue that cannot create a jump to definition, you can see it [here](https://rustdoc.crud.net/imperio/macro-jump-to-def/src/foo/check-source-code-urls-to-def-std.rs.html#35). r? ```@jyn514```
2022-06-20Improve code readability and documentationGuillaume Gomez-28/+40
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-25/+2
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-06-20Add support for macro in "jump to def" featureGuillaume Gomez-17/+54
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-1/+1
2022-06-09Auto merge of #97772 - GuillaumeGomez:minifier-update, r=notriddlebors-4/+6
Update minifier version to 0.2.1 This change and these changes come from an idea of `@camelid:` instead of creating a string, we just `write` the type into the file directly. I don't think it'll have a big impact on perf but it's still a potential small improvement. r? `@notriddle`
2022-06-07Update minifier version to 0.2.1Guillaume Gomez-4/+6
2022-06-06Rollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jshaMatthias Krüger-0/+7
Add empty impl blocks if they have documentation Fixes https://github.com/rust-lang/rust/issues/90866. The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with https://github.com/rust-lang/rust/pull/89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ```@Mark-Simulacrum).``` It looks like this: ![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png) cc ```@jyn514``` r? ```@camelid```
2022-06-04Don't generate "Impls on Foreign Types" for stdJacob Hoffman-Andrews-4/+3
Hack: many traits and types in std are re-exported from core or alloc. In general, rustdoc is capable of recognizing these implementations as being on local types. However, in at least one case, rustdoc gets confused and labels an implementation as being on a foreign type. To make sure that confusion doesn't pass on to the reader, consider all implementations in std, core, and alloc to be on local types.
2022-06-02Rollup merge of #97613 - jsha:implementation-is-on-local-type, r=GuillaumeGomezYuki Okushi-6/+3
rustdoc: Improve calculation of "Impls on Foreign Types" The existing code to calculate whether an implementation was on a "Foreign Type" was duplicated across the sidebar generation and the page generation. It also came to the wrong conclusion for some cases where both the trait and the "for" type were re-exports. This PR extracts the logic into a method of `Impl`, breaks it into a multi-line method so it can be commented, and adds a case for when the trait and the "for" type came from the same crate. This fixes some cases - like the platform-specific integer types (`__m256`, `__m128`, etc). But it doesn't fix all cases. See the screenshots below. [Before](https://doc.rust-lang.org/nightly/std/clone/trait.Clone.html#foreign-impls): <img src="https://user-images.githubusercontent.com/220205/171338226-59ce6daf-3d76-4bad-bc8d-72a8259a8f43.png" width=200> [After](https://rustdoc.crud.net/jsha/implementation-is-on-local-type/std/clone/trait.Clone.html): <img src="https://user-images.githubusercontent.com/220205/171338147-28308a65-1597-4223-be47-9550062404dd.png" width=200> The remaining types (`CString`, `NulError`, etc) are all from the `alloc` crate, while the `Clone` trait is from the `core` crate. Since `CString` and `Clone` are both re-exported by `std`, they are logically local to each other, but I couldn't figure out a good way to detect that in this code. I figure this is still a good step forward. Related: #97610 r? `@camelid`
2022-06-01Improve calculation of "Impls on Foreign Types"Jacob Hoffman-Andrews-6/+3
2022-05-31rustdoc: also index raw pointersMichael Howell-2/+3
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-05-31rustdoc: also index impl traitMichael Howell-6/+24
2022-05-31Display empty impl blocks if they have documentationsGuillaume Gomez-0/+7
2022-05-30Auto merge of #97489 - GuillaumeGomez:settings-js-disabled, r=notriddlebors-0/+5
Add sentence in case JS is disabled on settings.html page Instead of having an empty page, it'll look like this: ![Screenshot from 2022-05-28 17-46-23](https://user-images.githubusercontent.com/3050060/170833333-e1a59c2b-27ca-47da-9c08-2356e4a689cb.png) r? `@notriddle`
2022-05-29Fix order of closing HTML elements in rustdoc outputJan-Erik Rediger-1/+1
2022-05-29Auto merge of #96652 - notriddle:notriddle/self, r=GuillaumeGomezbors-16/+55
rustdoc: include impl generics / self in search index Fixes #92205
2022-05-28Improve settings page display with disabled javascriptGuillaume Gomez-0/+5
2022-05-27Pass Context as a &mut to allow to remove RefCell fieldsGuillaume Gomez-100/+112
2022-05-27cleanup librustdoc by making parent stack store itemsMichael Howell-15/+2
2022-05-26rustdoc: factor orphan impl items into an actual structMichael Howell-5/+7
2022-05-25rustdoc: include impl generics / self in search indexMichael Howell-13/+63
2022-05-24fix clippy perf lintsklensy-3/+5
2022-05-24fix simple clippy lintsklensy-10/+10
2022-05-23Auto merge of #94053 - GuillaumeGomez:fields-stripped, r=notriddlebors-11/+11
rustdoc: Remove fields_stripped fields (and equivalents) Fixes #90588. r? `@camelid`
2022-05-22Auto merge of #97177 - oli-obk:const-stability, r=davidtwcobors-4/+1
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared Continuation of #93960 `@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
2022-05-21Remove fields_stripped fields (and equivalents)Guillaume Gomez-11/+11
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-53/+57
2022-05-19Add and use stability helper methodsJacob Pratt-4/+1
This avoids an ambiguity (when reading) where `.level.is_stable()` is not immediately clear whether it is general stability or const stability.
2022-05-18Move some DOM generation into the HTML settings file directlyGuillaume Gomez-3/+13
2022-05-17rustdoc: make search.js a moduleJacob Hoffman-Andrews-1/+7
Previously, search.js relied on the DOM and the `window` object. It can now be loaded in the absence of the DOM, for instance by Node. The same is true of search-index.js. This allows removing a lot of code from src/tools/rustdoc-js/tester.js that tried to parse search.js and extract specific functions that were needed for testing.
2022-05-14Remove theme picker buttonGuillaume Gomez-1/+0
2022-05-12rustdoc: remove weird, unused variable from source-files.jsMichael Howell-1/+1
2022-05-12Auto merge of #96974 - matthiaskrgr:rollup-jd4otnc, r=matthiaskrgrbors-3/+5
Rollup of 5 pull requests Successful merges: - #95896 (Note the contacts for the nvptx64 target(s)) - #96860 (openbsd: convert futex timeout managment to Timespec usage) - #96939 (Fix settings page CSS) - #96941 (update graphviz links) - #96968 (Add tests for #96806) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-11Add missing CSS file for settings pageGuillaume Gomez-3/+5
2022-05-10update rustdoclcnr-1/+1
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-2/+2
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-07Rollup merge of #96636 - GuillaumeGomez:fix-jump-to-def-regression, r=notriddleGuillaume Gomez-3/+1
Fix jump to def regression https://github.com/rust-lang/rust/pull/93803 introduced a regression in the "jump to def" feature. This fixes it. Nice side-effect: it adds a new regression test. :) I also used this opportunity to add documentation about this unstable feature in the rustdoc book. cc ``@cjgillot`` r? ``@notriddle``
2022-05-06Remove unneeded SpanMapVisitor::visit_generics functionGuillaume Gomez-13/+1
2022-05-06Rollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomezGuillaume Gomez-15/+96
rustdoc: ensure HTML/JS side implementors don't have dups Fixes #94641 Rendered: - https://notriddle.com/notriddle-rustdoc-test/impl-dups/std/iter/trait.Iterator.html - https://notriddle.com/notriddle-rustdoc-test/impl-dups/core/iter/trait.Iterator.html
2022-05-06Fix reexports missing from the search indexGuillaume Gomez-2/+16
2022-05-05rustdoc: ensure HTML/JS side implementors don't have dupsMichael Howell-15/+96
2022-05-03Rollup merge of #93097 - GuillaumeGomez:settings-js, r=jshaYuki Okushi-141/+10
Switch settings menu to full js Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before. ![Screenshot from 2022-01-19 23-06-59](https://user-images.githubusercontent.com/3050060/150221936-fd1a1e76-06b6-4416-a653-dbae111979ed.png) You can test it [here](https://rustdoc.crud.net/imperio/settings-js/doc/foo/index.html). r? ``@jsha``
2022-05-02Fix regression in link-to-definition introduced in #93803Guillaume Gomez-2/+12
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-11/+2
2022-04-30Move settings into full JSGuillaume Gomez-141/+10
2022-04-21Remove .woff font filesGuillaume Gomez-18/+9
2022-04-16Rollup merge of #96118 - GuillaumeGomez:cleanup-def-id-item-id, r=notriddleDylan DPC-39/+39
rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability As `@notriddle` mentioned in https://github.com/rust-lang/rust/pull/96091, the field name is inaccurate. This PR fixes it by renaming it accordingly to its real type. r? `@notriddle`
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-39/+39
2022-04-15Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelixDylan DPC-2/+5
remove find_use_placement A more robust solution to finding where to place use suggestions was added in #94584. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it instead of calling `find_use_placement` Fixes #94941