about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
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
2020-12-11use strip_prefix over slicing (clippy::manual_strip)Matthias Krüger-2/+2
2020-12-11Fix main section position so that the search input remains clickableGuillaume Gomez-0/+4
2020-12-11Fix item name display on mobileGuillaume Gomez-1/+1
2020-12-10Rollup merge of #79896 - GuillaumeGomez:more-elements-focus, r=ManishearthTyler Mandry-20/+23
Make search results tab and help button focusable with keyboard Fixes https://github.com/rust-lang/rust/issues/79859. I replaced the element with `button` tag, which allows to focus them (and "click" on them using "enter") using only the keyboard. cc ``@sersorrel`` r? ``@Manishearth``
2020-12-10Rollup merge of #79809 - Eric-Arellano:split-once, r=matkladTyler Mandry-4/+2
Dogfood `str_split_once()` Part of https://github.com/rust-lang/rust/issues/74773. Beyond increased clarity, this fixes some instances of a common confusion with how `splitn(2)` behaves: the first element will always be `Some()`, regardless of the delimiter, and even if the value is empty. Given this code: ```rust fn main() { let val = "..."; let mut iter = val.splitn(2, '='); println!("Input: {:?}, first: {:?}, second: {:?}", val, iter.next(), iter.next()); } ``` We get: ``` Input: "no_delimiter", first: Some("no_delimiter"), second: None Input: "k=v", first: Some("k"), second: Some("v") Input: "=", first: Some(""), second: Some("") ``` Using `str_split_once()` makes more clear what happens when the delimiter is not found.
2020-12-10Make search results tab and help button focusable with keyboardGuillaume Gomez-20/+23
2020-12-09Rollup merge of #79862 - GuillaumeGomez:tab-lock, r=ManishearthTyler Mandry-16/+17
Remove tab-lock and replace it with ctrl+up/down arrows to switch between search result tabs Fixes https://github.com/rust-lang/rust/issues/65212 What took the longest time was to update the help popup in the end. r? `@Manishearth`
2020-12-09Remove tab-lock and replace it with ctrl+up/down arrows to switch between ↵Guillaume Gomez-16/+17
search result tabs
2020-12-09Hide associated constants too when collapsing implementationGuillaume Gomez-3/+6
2020-12-08use .contains() or .any() instead of find(x).is_some() (clippy::search_is_some)Matthias Krüger-1/+1
2020-12-07Dogfood 'str_split_once() with librustdocEric Arellano-4/+2
2020-12-06Use `summary_opts()` in another spotCamelid-1/+1
I added `summary_opts()` before I cut the branch for #77686 (2 months ago!), so this "slipped through the cracks".
2020-12-05Move tooltips messages to CSS instead of inside HTMLGuillaume Gomez-65/+47
2020-12-03Make `length_limit` a `usize`Camelid-4/+2
2020-12-03Use `createElement` and `innerHTML` instead of `DOMParser`Camelid-5/+3
@GuillaumeGomez was concerned about browser compatibility.
2020-12-03Render Markdown in search resultsCamelid-42/+155
Previously Markdown documentation was not rendered to HTML for search results, which led to the output not being very readable, particularly for inline code. This PR fixes that by rendering Markdown to HTML with the help of pulldown-cmark (the library rustdoc uses to parse Markdown for the main text of documentation). However, the text for the title attribute (the text shown when you hover over an element) still uses the plain-text rendering since it is displayed in browsers as plain-text. Only these styles will be rendered; everything else is stripped away: * *italics* * **bold** * `inline code`
2020-12-01Auto merge of #79596 - m-ou-se:rollup-hujx3c7, r=m-ou-sebors-17/+73
Rollup of 11 pull requests Successful merges: - #79038 (Change ui test that are run-pass and that do not test the compiler to library tests) - #79184 (Stop adding '*' at the end of slice and str typenames for MSVC case) - #79227 (Remove const_fn_feature_flags test) - #79444 (Move const ip in ui test to unit test) - #79522 (Validate lint docs separately.) - #79525 (Add -Z normalize-docs and enable it for compiler docs) - #79527 (Move intra-doc link tests into a subdirectory) - #79548 (Show since when a function is const in stdlib) - #79568 (update Miri) - #79573 (Update with status for various NetBSD ports.) - #79583 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-01Auto merge of #78876 - GuillaumeGomez:better-setting-keyboard-ux, r=jyn514bors-55/+62
Make keyboard interactions in the settings menu more pleasant #78868 improved the keyboard interactions with the settings page. This PR goes a bit further by allowing more than just "space" to toggle the checkboxes. r? `@jyn514`
2020-11-29Add support for stable-const-since in docs on items (standalone or assoc)Rune Tynan-17/+73
2020-11-29Rollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514Dylan DPC-51/+70
Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short` Follow-up of #79300 The point of this PR is to make the CSS class more accurate since it's not only about stability anymore. r? ``@jyn514``
2020-11-24Add `summary_opts()` for Markdown summary rendering optionsCamelid-6/+8
We have a similar function `opts()` that is for rendering the main body of the documentation, but until now we just constructed the options for rendering summaries on the fly. This is a problem if/when we change the enabled options since the different places can get out-of-sync.
2020-11-24Clean up document_item_info callsGuillaume Gomez-7/+20
2020-11-24Rename "stability" CSS class to "item-info"Guillaume Gomez-46/+52
2020-11-24Show hidden elements by default when JS is disabledGuillaume Gomez-0/+10
2020-11-24Rollup merge of #79310 - jyn514:fold-item-cleanup, r=GuillaumeGomezJonas Schievink-1/+1
Make `fold_item_recur` non-nullable This gets rid of a bunch of `unwrap()`s and makes it a little more clear what's going on. Originally I wanted to make `fold_item` non-nullable too, which would have been a lot nicer to work with, but unfortunately `stripper` does actually return `None` in some places. I might make a follow-up moving stripper to be special and not a pass so that passes can be non-nullable. Found while working on https://github.com/rust-lang/rust/issues/76998.
2020-11-22Make `fold_item_recur` non-nullableJoshua Nelson-1/+1
This gets rid of a bunch of `unwrap()`s and makes it a little more clear what's going on. Originally I wanted to make `fold_item` non-nullable too, which would have been a lot nicer to work with, but unfortunately `stripper` does actually return `None` in some places. I might make a follow-up moving stripper to be special and not a pass so that passes can be non-nullable.
2020-11-22Prevent feature information to be hidden if it's on the impl directlyGuillaume Gomez-2/+8
2020-11-18add [src] links to methods on a trait's pageNixon Enraght-Moony-24/+17
2020-11-18Extract write_srclink to its own methodNixon Enraght-Moony-30/+24
2020-11-17Add `from_def_id_and_kind` reducing duplication in rustdocJoshua Nelson-1/+0
- Add `Item::from_hir_id_and_kind` convenience wrapper - Make name parameter mandatory `tcx.opt_item_name` doesn't handle renames, so this is necessary for any item that could be renamed, which is almost all of them. - Override visibilities to be `Inherited` for enum variants `tcx.visibility` returns the effective visibility, not the visibility that was written in the source code. `pub enum E { A, B }` always has public variants `A` and `B`, so there's no sense printing `pub` again. - Don't duplicate handling of `Visibility::Crate` Instead, represent it as just another `Restricted` path.
2020-11-17Use DefPath for clean::Visibility, not clean::PathJoshua Nelson-5/+18
Visibility needs much less information than a full path, since modules can never have generics. This allows constructing a Visibility from only a DefId. Note that this means that paths are now normalized to their DefPath. In other words, `pub(self)` or `pub(super)` now always shows `pub(in path)` instead of preserving the original text.
2020-11-17Rollup merge of #79126 - jyn514:auto, r=GuillaumeGomezMara Bos-3/+3
Remove duplicate `Trait::auto` field It was exactly the same as `is_auto`. I found this while working on #78082, but it's not required for that PR. r? `@GuillaumeGomez`
2020-11-17Rollup merge of #79125 - jyn514:fewer-types, r=GuillaumeGomezMara Bos-6/+9
Get rid of clean::{Method, TyMethod} They're redundant and almost the same as `clean::Function`. I needed this for https://github.com/rust-lang/rust/pull/78082, although I forget why. r? `@GuillaumeGomez`
2020-11-17Rollup merge of #79069 - jyn514:class-none, r=GuillaumeGomezMara Bos-17/+16
Get rid of `highlight::Class::None` This is mostly me learning the codebase for https://github.com/rust-lang/rust/pull/77939, so feel free to close the PR. It does have the small benefit that we statically know rustdoc isn't generating useless `span`s, though. r? `@GuillaumeGomez` cc `@matklad`
2020-11-17Rollup merge of #74293 - GuillaumeGomez:rustdoc-test-compiler-output-color, ↵Mara Bos-1/+2
r=jyn514 Rustdoc test compiler output color Fixes #72915 We just need to be sure it doesn't break rustdoc doctests' compilation checks. Maybe some other unforeseen consequences too? r? `@ehuss` cc `@rust-lang/rustdoc`
2020-11-17Simplfy color availability checkGuillaume Gomez-1/+2
2020-11-17Rollup merge of #77939 - GuillaumeGomez:fix-source-code-dos-backline, r=jyn514Mara Bos-12/+27
Ensure that the source code display is working with DOS backline Fixes #76361. cc ````@lzutao```` r? ````@jyn514````
2020-11-17Remove duplicate `Trait::auto` fieldJoshua Nelson-3/+3
It was exactly the same as `is_auto`.
2020-11-16Get rid of clean::MethodJoshua Nelson-5/+9
Replace it instead with `(clean::Function, Option<hir::Defaultness>)`.
2020-11-16Get rid of clean::TyMethodJoshua Nelson-2/+1
It's the same as clean::Function.
2020-11-16Rollup merge of #79061 - jyn514:no-pub, r=GuillaumeGomezMara Bos-168/+168
Make all rustdoc functions and structs crate-private This gives warnings when code is no longer used, which will be helpful when https://github.com/rust-lang/rust/pull/77820 and https://github.com/rust-lang/rust/pull/78082 land. AFAIK no one is using this API. r? ``@GuillaumeGomez`` cc ``@rust-lang/rustdoc``
2020-11-16Rollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomezMara Bos-32/+50
Add tests and improve rendering of cfgs on traits Shows the additional features required to get the trait implementation, suppressing any already shown on the current page. One interesting effect from this is if you have a cfg-ed type, implementing a cfg-ed trait (so the implementation depends on both cfgs), you will get the inverted pair of cfgs shown on each page: ![image](https://user-images.githubusercontent.com/81079/97904671-207bdc00-1d41-11eb-8144-707e8017d2b6.png) ![image](https://user-images.githubusercontent.com/81079/97904700-27a2ea00-1d41-11eb-8b9f-e925ba339044.png) The hidden items on the trait implementation also now get the correct cfgs displayed on them. Tests are blocked on #78673. fixes #68100 cc #43781
2020-11-15Add test to ensure that no DOS backline (\r\n) doesn't create extra backline ↵Guillaume Gomez-14/+27
in source rendering
2020-11-15Make `Playground` public for error index generatorJoshua Nelson-2/+2
2020-11-15Make `markdown` module public for doc-testsJoshua Nelson-13/+13
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-183/+183
This gives warnings about dead code.
2020-11-15Ensure that the source code display is working with DOS backlineGuillaume Gomez-0/+2