summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-01-20Add FIXME for visibility of a moduleCamelid-0/+3
2021-01-20Update `find_nearest_parent_module`Camelid-3/+3
2021-01-20Prefer `pub(crate)` over no modifierCamelid-3/+3
2021-01-20Handle `pub(super)`Camelid-1/+9
2021-01-20Fix bugs; fix and add testsCamelid-47/+47
2021-01-20rustdoc: Render visibilities succinctlyCamelid-20/+36
2020-12-25Auto merge of #80226 - ThePuzzlemaker:issue-80004-fix, r=jyn514,petrochenkovbors-12/+24
Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers Previously, edition-specific keywords (such as `async` and `await`) were not highlighted in code blocks, regardless of what edition was set. With this PR, this issue is fixed. Now, the following behavior happens: - When a code block is explicitly set to edition X, keywords from edition X are highlighted - When a code block is explicitly set to a version that does not contain those keywords from edition X (e.g. edition Y), keywords from edition X are **not** highlighted - When a code block has no explicit edition, keywords from the edition passed via `--edition` to rustdoc are highlighted For example, a project set with `edition = "2015"` in its `Cargo.toml` would not highlight `async`/`await` unless the code block was set to `edition2018`. Additionally, a project set with `edition = "2018"` in its `Cargo.toml` *would* highlight `async`/`await` unless the code block was set to a version that did not contain those keywords (e.g. `edition2015`). This PR fixes #80004. r? `@jyn514`
2020-12-25Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinembors-1/+1
Remap instrument-coverage line numbers in doctests This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done, and rustdoc still does not output the correct filename when running doctests in a workspace. Part of #79417 although I dont consider that fixed until both filenames and columns are mapped correctly. r? `@richkadel` I might jump on zulip the comming days. Still need to figure out how to properly write tests for this, and deal with other doctest issues in the meantime.
2020-12-24rustdoc: Highlight edition-specific keywords correctly in code blocks, ↵ThePuzzlemaker-12/+24
accounting for code block edition modifiers This is a squash of these commits: - Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers - Fix unit tests - Revert changes to rustc_span::symbol to prepare for merge of #80272 - Use new Symbol::is_reserved API from #80272 - Remove unused import added by accident when merging
2020-12-24Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, ↵bors-65/+47
r=Nemo157 Move tooltips messages out of html First thing first: nothing in the output has changed. You still have the "i" on the left of code blocks examples when they have `ignore`, `compile_fail`, `should_panic` and `edition`. The behavior also remains the same: when you hover the "i", you have the corresponding message showing up. So now, why this PR then? I realized recently that we were actually generating those messages into the HTML every time whereas all messages are the same (except for the edition ones, I'll come back to it later). So instead of generating more content, I simply moved it inside the CSS thanks to pseudo elements (`::before` and `::after`). The message is now inside `::after` and we use the `::before` to have the small triangle on the left of the message. So now, we have less HTML generated which is seems pretty nice. So now, back to the `edition` change: the message is globally the same, but the "edition" itself can be different (2015 or 2018 currently, I expect 2021 to arrive not too far in the future). So the only difference for it is that I added a new attribute on the tooltip called `edition` which contains this information. Then, the `::after` uses it inside its `content` (you can get the content of an element's attribute by using `attr` and concat different strings by simply having them after the other). Don't hesitate if a part of my explanations isn't clear. r? `@jyn514`
2020-12-23Update HTML DOM attribute "edition" to "data-edition"Guillaume Gomez-2/+2
2020-12-23Auto merge of #80099 - jyn514:visibility-on-demand, r=GuillaumeGomezbors-35/+44
Remove `DefPath` from `Visibility` and calculate it on demand Depends on #80090 and should not be merged before. Helps with https://github.com/rust-lang/rust/issues/79103 and https://github.com/rust-lang/rust/issues/76382. cc https://github.com/rust-lang/rust/pull/80014#issuecomment-746810284 - `@nnethercote` I figured it out! It was simpler than I expected :) This brings the size of `clean::Visibility` down from 40 bytes to 8. Note that this does *not* remove `clean::Visibility`, even though it's now basically the same as `ty::Visibility`, because the `Invsible` variant means something different from `Inherited` and I thought it would be be confusing to merge the two. See the new comments on `impl Clean for ty::Visibility` for details.
2020-12-23Auto merge of #80095 - jyn514:stability-on-demand, r=GuillaumeGomezbors-36/+54
[rustdoc] Calculate stability, const_stability, and deprecation on-demand Previously, they would always be calculated ahead of time, which bloated the size of `clean::Item`. Builds on https://github.com/rust-lang/rust/pull/80090 and should not be merged before. Helps with https://github.com/rust-lang/rust/issues/79103 and https://github.com/rust-lang/rust/issues/76382. cc https://github.com/rust-lang/rust/pull/80014#issuecomment-746810284 This brings `Item` down to 568 bytes, down from 616.
2020-12-21Auto merge of #80206 - poliorcetics:rustdoc-default-langstring, ↵bors-39/+29
r=GuillaumeGomez,jyn514 impl Default for LangString, replacing all_false by default Fix #80015 `@rustbot` label C-cleanup T-rustdoc A-markdown-parsing
2020-12-20Fix incorrect logic when merging matchesJoshua Nelson-2/+3
2020-12-20Remove unnecessary scopeJoshua Nelson-0/+2
2020-12-20Get rid of `locate()` in markdown handlingJoshua Nelson-68/+62
This function was unfortunate for several reasons: - It used `unsafe` because it wanted to tell whether a string came from the same *allocation* as another, not just whether it was a textual match. - It recalculated spans even though they were already available from pulldown - It sometimes *failed* to calculate the span, which meant it was always possible for the span to be `None`, even though in practice that should never happen. This commit has several cleanups: - Make the span required - Pass through the span from pulldown in the `HeadingLinks` and `Footnotes` iterators - Only add iterator bounds on the `impl Iterator`, not on `new` and the struct itself.
2020-12-20impl Default for LangString, replacing all_false by defaultAlexis Bourget-39/+29
2020-12-19Remap instrument-coverage line numbers in doctestsArpad Borsos-1/+1
This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done. Part of issue #79417.
2020-12-18Auto merge of #80154 - GuillaumeGomez:str-to-symbol, r=jyn514bors-2/+2
Continue String to Symbol conversion in rustdoc (2) Follow-up of #80119. This is the last one (and I actually expected more conversions but seems like it was the last one remaining...). r? `@jyn514`
2020-12-18Remove `DefPath` from `Visibility` and calculate it on demandJoshua Nelson-36/+49
2020-12-18Calculate stability, const_stability, and deprecation on-demandJoshua Nelson-36/+54
Previously, they would always be calculated ahead of time, which bloated the size of `clean::Item`.
2020-12-18Continue String to Symbol conversion in rustdocGuillaume Gomez-2/+2
2020-12-18Auto merge of #80090 - jyn514:tcx-in-render, r=GuillaumeGomezbors-54/+83
Pass a `TyCtxt` through to `FormatRender` This is the next step after https://github.com/rust-lang/rust/pull/79957 for https://github.com/rust-lang/rust/issues/76382. Eventually I plan to use this to remove `stability`, `const_stability`, and `deprecation` from `Item`, but that needs more extensive changes (in particular, https://github.com/rust-lang/rust/pull/75355 or something like it). This has no actual changes to behavior, it's just moving types around. ccc https://github.com/rust-lang/rust/pull/80014#issuecomment-746810284
2020-12-18Auto merge of #80119 - GuillaumeGomez:str-to-symbol, r=jyn514bors-22/+21
Continue String to Symbol conversion in rustdoc Follow-up of https://github.com/rust-lang/rust/pull/80091. This PR is already big enough so I'll stop here before the next one. r? `@jyn514`
2020-12-17Continue String to Symbol conversion in rustdocGuillaume Gomez-22/+21
2020-12-17Make it compileJoshua Nelson-53/+81
2020-12-17[tmp] Pass `TyCtxt` through to the render backendJoshua Nelson-2/+3
First actually useful step in https://github.com/rust-lang/rust/issues/76382 This doesn't yet compile because there's no way to get a `Lrc<Session>` from a TyCtxt, only a `&Session`.
2020-12-17Rollup merge of #80047 - jyn514:more-symbols, r=GuillaumeGomezGuillaume Gomez-14/+18
Use more symbols in rustdoc Builds on https://github.com/rust-lang/rust/pull/80044 and should not be merged before. I want to test if this is actually faster before merging it, there was a lot of `to_string()` calls so I'm not sure it will actually help. That means I have to wait for 80044 to get merged before running perf. r? `@ghost`
2020-12-17Auto merge of #80091 - GuillaumeGomez:str-to-symbol, r=jyn514bors-9/+6
Replace String with Symbol where possible The same as #80047 but on different types. Might be interesting to run some perf comparison. r? `@jyn514`
2020-12-16Replace String with Symbol where possibleGuillaume Gomez-9/+6
2020-12-16Allow `since="TBD"` for rustc_deprecatedbstrie-1/+5
2020-12-16Auto merge of #80041 - jyn514:shrink-item, r=GuillaumeGomezbors-6/+13
Get rid of `clean::Deprecation` This brings the size of `item.deprecation` from 56 to 16 bytes. Helps with #79103 and https://github.com/rust-lang/rust/issues/76382, in the same vein as https://github.com/rust-lang/rust/pull/79957. r? `@GuillaumeGomez`
2020-12-15Use `Symbol`s for crate namesJoshua Nelson-14/+18
2020-12-15Auto merge of #80044 - jyn514:smaller-name, r=GuillaumeGomezbors-16/+13
[rustdoc] Switch to Symbol for item.name This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much. Helps with #79103. r? `@GuillaumeGomez`
2020-12-15Rollup merge of #79796 - ↵Guillaume Gomez-3/+6
GuillaumeGomez:hide-associated-const-when-collapsing, r=jyn514 Hide associated constants too when collapsing implementation Fixes #71849. r? `@jyn514`
2020-12-15Rollup merge of #79379 - GuillaumeGomez:no-js-not-hidden, r=Nemo157Guillaume Gomez-0/+10
Show hidden elements by default when JS is disabled Fixes #79301. A lot of things are hidden by default which shouldn't when JS is disabled. This PR fixes it. Before: ![Screenshot from 2020-11-24 14-10-16](https://user-images.githubusercontent.com/3050060/100099361-a16d5580-2e5f-11eb-891b-a4c005aeb1d0.png) After: ![after](https://user-images.githubusercontent.com/3050060/100099382-a6caa000-2e5f-11eb-8190-14f330aff9a2.png) r? `@jyn514`
2020-12-14Switch to Symbol for item.nameJoshua Nelson-16/+13
This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much.
2020-12-14Get rid of `clean::Deprecation`Joshua Nelson-6/+13
This brings the size of `item.deprecation` from 56 to 16 bytes.
2020-12-14Rollup merge of #80013 - poliorcetics:rustdoc-test-refactor, r=jyn514Guillaume Gomez-74/+69
Refactor test_lang_string_parse to make it clearer Follows https://github.com/rust-lang/rust/pull/79454#discussion_r540190949 A small PR made to refactor a test in rustdoc that was becoming unwieldy. ``@rustbot`` label T-rustdoc r? ``@jyn514``
2020-12-14Rollup merge of #79936 - GuillaumeGomez:mobile-fix-item-name, r=Nemo157,jyn514Guillaume Gomez-1/+5
Fix item name display on mobile Fixes https://github.com/rust-lang/docs.rs/issues/1200 ![Screenshot_20201211-200931](https://user-images.githubusercontent.com/3050060/101944457-0c06eb00-3bed-11eb-8f63-a4d4fd3cbb56.jpg) ![Screenshot_20201211-195846](https://user-images.githubusercontent.com/3050060/101944459-0d381800-3bed-11eb-91ff-815a2af7ca72.jpg) cc `@jyn514` r? `@Nemo157`
2020-12-13Refactor test_lang_string_parse to make it clearerAlexis Bourget-74/+69
2020-12-13Rollup merge of #79985 - GuillaumeGomez:fix-submit-event, r=jyn514Yuki Okushi-1/+1
Fixes submit event of the search input Fixes https://github.com/rust-lang/rust/issues/79960 It's a very funny corner case: In HTML, when a button follows an input (in a `form`), if the enter keep is pressed on the input, instead of sending the submit event to the input, it'll create a click event on the button following it, which in this case made the help popup show up whenever "enter" was pressed. cc `@camelid` r? `@jyn514`
2020-12-13Rollup merge of #79973 - camelid:rustdoc-search-tab-color, r=GuillaumeGomezYuki Okushi-1/+1
rustdoc light theme: Fix CSS for selected buttons Fixes #79961. The background was dark before, which made the text impossible to read. Now the button doesn't override the background, and the only thing it does is add a light-blue top border. Ultimately, the search results tabs now look very similar to how they used to look. r? `@GuillaumeGomez`
2020-12-13Rollup merge of #79940 - matthiaskrgr:cl15ppy, r=Dylan-DPCYuki Okushi-2/+2
fix more clippy::complexity findings fix clippy::unnecessary_filter_map use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn) fix clippy::{needless_bool, manual_unwrap_or} don't clone types that are copy (clippy::clone_on_copy) don't convert types into identical types with .into() (clippy::useless_conversion) use strip_prefix over slicing (clippy::manual_strip) r? ``@Dylan-DPC``
2020-12-13Fixes submit event of the search inputGuillaume Gomez-1/+1
In HTML, when a button follows an input, if the enter keep is pressed on the input, instead of sending the submit event to the input, it'll create a click event on the button following it, which in this case made the help popup show up whenever "enter" was pressed.
2020-12-12rustdoc light theme: Fix CSS for selected buttonsCamelid-1/+1
The background was dark before, which made the text impossible to read. Now the background is white, which is how selected `div`s are rendered. As a result, the search results tabs now look identical to how they used to look (before #79896).
2020-12-12Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomezbors-13/+30
[rustdoc] Calculate span information on demand instead of storing it ahead of time This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`. ~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback. Helps with #79103
2020-12-12Calculate span info on-demand instead of ahead of timeJoshua Nelson-15/+27
This should *vastly* reduce memory usage.
2020-12-12Pass Session into rendererJoshua Nelson-0/+5