about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2022-12-13rustdoc: simplify popover CSSMichael Howell-6/+3
* Merge the color-changing block into the regular rules, which was probably written that way because it used to be in the theme files, but has no reason to be written this way now that it's in rustdoc.css * Get rid of redundant `display: block`, since `position: absolute` blockifies the layout anyway.
2022-12-13Combine projection and opaque into aliasMichael Goulet-5/+6
2022-12-13rustdoc: apply `pre-wrap` CSS to code-wrapped linksMichael Howell-2/+2
This is common syntax used for intra-doc links, so fixing it should help with doc formatting.
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-3/+3
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-4/+4
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-1/+1
2022-12-13Auto merge of #105612 - oli-obk:bind_rustdoc, r=GuillaumeGomezbors-101/+162
use ty::Binder in rustdoc instead of `skip_binder` r? `@GuillaumeGomez` this is a preliminary cleanup required to be able to normalize correctly/conveniently in rustdoc
2022-12-13Improve rustdoc markdown variable namingGuillaume Gomez-5/+5
2022-12-13Rollup merge of #105639 - notriddle:notriddle/text-css, r=GuillaumeGomezMatthias Krüger-3/+2
rustdoc: remove `type="text/css" from stylesheet links MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web." Like 07a243b2a46384235d7e2c08688978b7cf018973, but a few places that were missed the first time.
2022-12-13Rollup merge of #105629 - notriddle:notriddle/method-toggle-trait, ↵Matthias Krüger-3/+6
r=GuillaumeGomez rustdoc: stop treating everything in a trait item as a method This was added in 0b9b4b70683db6ef707755f520f139eb7b92a944 to fix the spacing on trait pages, but stopped being needed because 791f04e5a47ee78951552c7ed1545b2b01a44c74 stopped styling method-toggle. By only putting the method-toggle class on actual methods, the JS setting does the right thing.
2022-12-12rustdoc: remove `type="text/css" from stylesheet linksMichael Howell-3/+2
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web." Like 07a243b2a46384235d7e2c08688978b7cf018973, but a few places that were missed the first time.
2022-12-12rustdoc: stop treating everything in a trait item as a methodMichael Howell-3/+6
This was added in 0b9b4b70683db6ef707755f520f139eb7b92a944 to fix the spacing on trait pages, but stopped being needed because 791f04e5a47ee78951552c7ed1545b2b01a44c74 stopped styling method-toggle. By only putting the method-toggle class on actual methods, the JS setting does the right thing.
2022-12-12rustdoc: remove no-op CSS `.source pre { overflow: auto }`Michael Howell-1/+0
Since source pages use the `example-wrap` wrapper, this rule became redundant because there is already an `overflow-x: auto` rule.
2022-12-12Avoid trying to normalize unnormalizable typesOli Scherer-2/+6
2022-12-12Round 3: require binders for substsOli Scherer-28/+49
2022-12-12Round 2: make clean_middle_ty take a binderOli Scherer-56/+92
2022-12-12Round 1: add some binders (fails due to losing bound vars and then rebinding ↵Oli Scherer-26/+26
them with `Binder::dummy`)
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-14/+20
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-11Extend rustdoc hashtag prepended line testGuillaume Gomez-0/+8
2022-12-11Auto merge of #105554 - matthiaskrgr:rollup-ir60gc7, r=matthiaskrgrbors-3/+41
Rollup of 6 pull requests Successful merges: - #105411 (Introduce `with_forced_trimmed_paths`) - #105532 (Document behaviour of `--remap-path-prefix` with several matches) - #105537 (compiler: remove unnecessary imports and qualified paths) - #105539 (rustdoc: Only hide lines starting with `#` in rust code blocks ) - #105546 (Add some regression tests for #44454) - #105547 (Add regression test for #104582) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-11Rollup merge of #105539 - GuillaumeGomez:hashtag-prepended-lines-non-rust, ↵Matthias Krüger-3/+41
r=notriddle rustdoc: Only hide lines starting with `#` in rust code blocks Fixes https://github.com/rust-lang/rust/issues/105527. So before approving, this is a big question: in rust code blocks, in a line starts with a `#`, we hide it in the output. However, should we do the same for non-rust code blocks too? I think it's a bit problematic to do it because `#` can be used for many things but I prefer to check first with everyone (might also be worth updating documentation too). cc ``@rust-lang/rustdoc`` r? ``@notriddle``
2022-12-11Auto merge of #105457 - GuillaumeGomez:prevent-auto-blanket-impl-retrieval, ↵bors-0/+6
r=notriddle rustdoc: Prevent auto/blanket impl retrieval if there were compiler errors Fixes https://github.com/rust-lang/rust/issues/105404. I'm not sure happy about this fix but since it's how passes work (ie, even if there are errors, it runs all passes), I think it's fine as is. Just as a sidenote: I also gave a try to prevent running all passes in case there were compiler errors but then a lot of rustdoc tests were failing so I went for this fix instead. r? `@notriddle`
2022-12-10Add test for non-rust code block hashtag prepended linesGuillaume Gomez-0/+37
2022-12-10Don't take into account hashtag prepended lines if not in rust code blockGuillaume Gomez-3/+4
2022-12-10Clean up lifetimes in rustdoc syntax highlightingNilstrieb-24/+24
Removes a few lifetimes and renames some.
2022-12-09Rollup merge of #105504 - notriddle:notriddle/stab-css, r=GuillaumeGomezMatthias Krüger-27/+13
rustdoc: make stability badge CSS more consistent # Before ![image](https://user-images.githubusercontent.com/1593513/206763667-8e0deb74-be63-4906-8229-9a7eb51725c2.png) ![image](https://user-images.githubusercontent.com/1593513/206764007-6301c0e8-4594-4a41-ba93-105824dffee6.png) # After ![image](https://user-images.githubusercontent.com/1593513/206763698-e187cee2-3a50-4e48-b7b5-c3cfa41a797d.png) ![image](https://user-images.githubusercontent.com/1593513/206764058-3999ee67-1439-4c98-8216-b90575342aa8.png) # Description * They all get rounded corners now. A test case has been added for this, too. * There are now broadly two kinds of stability badge, where there used to be three: item-info "fat badge", and the "thin badge" in both item tables and in docblocks (which got merged). The fat badges can have icons, while the thin badges can't. * The old Ayu design doesn't make sense to me. Does anyone know why it was done that way?
2022-12-09Rollup merge of #105480 - notriddle:notriddle/sidebar-toggle-mobile-center, ↵Matthias Krüger-1/+0
r=GuillaumeGomez rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }` Since 8b001b4da0716936e0ca32303cc0e3c5e53e42f8 make the sidebar toggle a flex container, and already centers its content in desktop mode, this rule doesn't do anything.
2022-12-09rustdoc: make stability badge CSS more consistentMichael Howell-27/+13
* They all get rounded corners now. A test case has been added for this, too. * There are now broadly two kinds of stability badge, where there used to be three: item-info "fat badge", and the "thin badge" in both item tables and in docblocks (which got merged). The fat badges can have icons, while the thin badges can't.
2022-12-09Rollup merge of #105442 - notriddle:notriddle/docblock-table-css, ↵Matthias Krüger-10/+7
r=GuillaumeGomez rustdoc: clean up docblock table CSS # Preview http://notriddle.com/notriddle-rustdoc-demos/table-2/test_dingus/fn.test.html # Before ![image](https://user-images.githubusercontent.com/1593513/206364287-1b80eaaf-2e0e-4138-8b56-4aa8ff39abac.png) # After ![image](https://user-images.githubusercontent.com/1593513/206364209-d287d165-31be-4de1-9b43-05b35ce2a86b.png) # Details * The rule `display: block` had no noticeable effect. Technically, because markdown tables have a tbody and thead, they get wrapped in an [anonymous table box] in the CSS tree, nested within the `<table>` element's block layout box. This rule was added in #87230 to make the table side-scrolling, but this same issue was doubly fixed in #88742 by wrapping it in an explicit `<div>` tag. Since accessibility advocates recommend the wrapper div over marking the table as `display: block`, we'll stick with that. https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html * The rule `width: calc(100% - 2px)` had no visible effect, because the anonymous table box was not affected. * The style is tweaked to basically be the same style GitHub uses. In particular, it adds zebra stripes, and removes dotted borders. https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Markdown.20table.20styling [anonymous table box]: https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes
2022-12-09Rollup merge of #105427 - ↵Matthias Krüger-2/+2
GuillaumeGomez:dont-silently-ignore-rustdoc-errors, r=notriddle Dont silently ignore rustdoc errors I applied the suggestions from https://github.com/rust-lang/rust/pull/104995 and also checked the rustdoc-ui error but couldn't reproduce it. r? `@notriddle`
2022-12-09Rollup merge of #105387 - willcrichton:scrape-examples-ui-improvements, ↵Matthias Krüger-25/+95
r=notriddle Improve Rustdoc scrape-examples UI This PR combines a few different improvements to the scrape-examples UI. See a live demo here: https://willcrichton.net/misc/scrape-examples/small-first-example/clap/struct.Arg.html ### 1. The first scraped example now takes up significantly less screen height. Inserting the first scraped example takes up a lot of vertical screen space. I don't want this addition to overwhelm users, so I decided to reduce the height of the initial example in two ways: (A) the default un-expanded height is reduced from 240px (10 LOC) to 120px (5 LOC), and (B) the link to the example is now positioned *over* the example instead of *atop* the example (only on desktop though, not mobile). The changes to `scrape-examples.js` and `rustdoc.css` implement this fix. Here is what an example docblock now looks like: ![Screen Shot 2022-12-06 at 10 02 21 AM](https://user-images.githubusercontent.com/663326/205987450-3940063c-5973-4a34-8579-baff6a43aa9b.png) ### 2. Expanding all docblocks will not expand "More examples". The "More examples blocks" are huge, so fully expanding everything on the page would take up too much vertical space. The changes to `main.js` implement this fix. This is tested in `scrape-examples-toggle.goml`. ### 3. Examples from binary crates are sorted higher than examples from library crates. Code that is written as an example of an API is probably better for learning than code that happens to use an API, but isn't intended for pedagogic purposes. Unfortunately Rustc doesn't know whether a particular crate comes from an example target (only Cargo knows this). But we can at least create a proxy that prefers examples from binary crates over library crates, which we know from `--crate-type`. This change is implemented by adding a new field `bin_crate` in `Options` (see `config.rs`). An `is_bin` field has been added to the scraped examples metadata (see `scrape_examples.rs`). Then the example sorting metric uses `is_bin` as the first entry of a lexicographic sort on `(is_bin, example_size, display_name)` (see `render/mod.rs`). Note that in the future we can consider adding another flag like `--scrape-examples-cargo-target` that would pass target information from Cargo into the example metadata. But I'm proposing a less intrusive change for now. ### 4. The scrape-examples help page has been updated to reflect the latest Cargo interface. See `scrape-examples-help.md`. r? `@notriddle` P.S. once this PR and rust-lang/cargo#11450 are merged, then I think the scrape-examples feature is officially ready for deployment on docs.rs!
2022-12-08rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`Michael Howell-1/+0
Since 8b001b4da0716936e0ca32303cc0e3c5e53e42f8 make the sidebar toggle a flex container, and already centers its content in desktop mode, this rule doesn't do anything.
2022-12-08rustdoc: add GUI test case for docblock table colorsMichael Howell-1/+1
2022-12-08Prevent to try to retrieve auto and blanket implementations if there were ↵Guillaume Gomez-0/+6
errors before this pass
2022-12-07rustdoc: clean up docblock table CSSMichael Howell-10/+7
* The rule `display: block` had no noticeable effect. Technically, because markdown tables have a tbody and thead, they get wrapped in an [anonymous table box] in the CSS tree, nested within the `<table>` element's block layout box. This rule was added in #87230 to make the table side-scrolling, but this same issue was doubly fixed in #88742 by wrapping it in an explicit `<div>` tag. Since accessibility advocates recommend the wrapper div over marking the table as `display: block`, we'll stick with that. https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html * The rule `width: calc(100% - 2px)` had no visible effect, because the anonymous table box was not affected. * The style is tweaked to basically be the same style GitHub uses. In particular, it adds zebra stripes, and removes dotted borders. [anonymous table box]: https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes
2022-12-07Improve codeGuillaume Gomez-93/+90
2022-12-07Speed up execution a bit by removing some walksGuillaume Gomez-2/+21
2022-12-07Improve code readabilityGuillaume Gomez-15/+23
2022-12-07Fix missing const expression items visitGuillaume Gomez-115/+158
2022-12-07Improve calculation of scraped example minimized heightWill Crichton-5/+15
2022-12-07Revert crate_types change, add new bin_crate fieldWill Crichton-18/+22
2022-12-07Fix rustdoc error with no providec crate-type, fix scrape examples button ↵Will Crichton-3/+9
colors w/ themes
2022-12-07Fix es-checkWill Crichton-1/+1
2022-12-07Update scrape-examples help, fix documentation typosWill Crichton-9/+11
2022-12-07Include additional documentation for scrape-examples changesWill Crichton-2/+8
2022-12-07Only put title over example on large screensWill Crichton-10/+13
2022-12-07Improve several aspects of the Rustdoc scrape-examples UI.Will Crichton-33/+72
* Examples take up less screen height. * Snippets from binary crates are prioritized. * toggle-all-docs does not expand "More examples" sections.
2022-12-07Don't silently ignore errors that happen during renderingGuillaume Gomez-2/+2
2022-12-07Rollup merge of #105403 - notriddle:notriddle/item-stab-css, r=GuillaumeGomezMatthias Krüger-4/+2
rustdoc: simplify CSS selectors for item table `.stab` The module-item and import-item classes are attached to the item-left. Just target that, instead.
2022-12-06rustdoc: simplify CSS selectors for item table `.stab`Michael Howell-4/+2
The module-item and import-item classes are attached to the item-left. Just target that, instead.