about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2021-03-26Rollup merge of #83055 - aDotInTheVoid:selective-strip-item-doc, r=jyn514Dylan DPC-3/+15
[rustdoc] Don't document stripped items in JSON renderer. Fixes #80664, see [my comment there](https://github.com/rust-lang/rust/issues/80664#issuecomment-797557948) for why Note that we already do something similar in `convert_item`: https://github.com/rust-lang/rust/blob/bb4cdf8ec034dca5c056ec9295f38062e5b7e871/src/librustdoc/json/conversions.rs#L28-L31 ``@rustbot`` modify labels: +T-rustdoc +A-rustdoc-json r? ``@jyn514`` cc ``@CraftSpider``
2021-03-24Split clean::Constant enum into a struct and an enumGuillaume Gomez-46/+46
2021-03-24Rename clean::Constant did fields to def_idGuillaume Gomez-18/+18
2021-03-24Improve new Constant variants' nameGuillaume Gomez-20/+21
2021-03-24Store tcx and cache when they are used multiple times instead of calling ↵Guillaume Gomez-58/+66
functions every time
2021-03-24Rework rustdoc const typeGuillaume Gomez-608/+805
2021-03-24Don't call `item` on modules for json rendererNixon Enraght-Moony-3/+15
Closes #80664
2021-03-24Rollup merge of #83415 - camelid:remove-crate-module-option, r=jyn514Dylan DPC-85/+61
Remove unnecessary `Option` wrapping around `Crate.module` I'm wondering if it was originally there so that we could `take` the module which enables `after_krate` to take an `&Crate`. However, the two impls of `after_krate` only use `Crate.name`, so we can pass just the name instead.
2021-03-24Rollup merge of #83405 - r00ster91:deprecated_emoji, r=GuillaumeGomezDylan DPC-4/+13
Slight visual improvements to warning boxes in the docs First I noticed that sometimes the thumbs-down emoji in the docs is hard to see and hard to look at because the yellow emoji color and the color of the box below are so bright. Especially if you look at the screen late at night you can notice it. I thought I should change that so I added a black outline around the emoji. It works using the [`text-shadow`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow) property. It may be a bit hacky but it seems to work well and browser compatibility looks pretty good too: [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow#browser_compatibility). For consistency the microscope has the black border too. Alternatively I had `drop-shadow(0px 0px 1px black);` in mind but its [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow()#browser_compatibility) doesn't look as good and the blurry shadow probably doesn't look as good either. Then, I thought that now that I'm at it I could also try changing the purple color to a color you would rather expect to see for deprecation: red. For the red I've taken the blue and reused it as a foundation and moved it to the red color spectrum. But then I thought that the purple color could still be reused for something else: for the boxes that tell you about portability (e.g. _only supported on Unix_). These are currently blue. I think blue doesn't really represent danger like it should. Not being cross-platform represents a danger because if you want to compile for a different platform, your code may not compile anymore. Blue looks too friendly and is in my opinion more suitable for a box containing general information like for instance "This is available since 1.0.0". None of the current three box types (unstable, deprecated and portability) are that. I think purple is a better fit for it because it's kind of in the middle between "use it" and "don't use it". Deprecated is definitely "don't use it". To illustrate this better, here's a color spectrum: Blue = friendly, "use it". ![image](https://user-images.githubusercontent.com/35064754/112139891-9a6b0f80-8bd3-11eb-94e1-dc747a3d4cf9.png) Red = danger, "don't use it". And the purple in the middle (the color that the portability box now has) probably represents "use it if you have to", so it's not entirely friendly and not entirely a danger. That is why I think it fits. However I made one change to that existing purple: I made the outer color a bit brighter because it's outstandingly dark compared to the other outer colors of the other boxes. This is all subjective but in my opinion it looks nicer. At first you might need to get used to it though. Notice the box colors and the black outlines around the emoji shapes: ![image](https://user-images.githubusercontent.com/35064754/112139327-ebc6cf00-8bd2-11eb-88ac-25219b43a1a0.png) ![image](https://user-images.githubusercontent.com/35064754/112139392-000acc00-8bd3-11eb-90c2-81feec93c521.png)
2021-03-24Rollup merge of #83399 - camelid:rustdoc-priv-link-from-crate, r=jyn514Dylan DPC-3/+1
rustdoc: Record crate name instead of using `None` Fixes #83365. r? `@jyn514`
2021-03-24Rollup merge of #83393 - GuillaumeGomez:codeblock-tooltip-position, r=Nemo157Dylan DPC-1/+1
Codeblock tooltip position The codeblocks tooltips were misplaced. Normally, there is no top margin applied to a tooltip unless the codeblock is the first element of the doc block. The CSS rule was too vague though, applying it to all tooltips where the codeblock was the first child of its parent. Which can be easily seen with lists: Before: ![Screenshot from 2021-03-22 22-05-16](https://user-images.githubusercontent.com/3050060/112059812-a667ba80-8b5c-11eb-88dd-1c598ceb3766.png) After: ![Screenshot from 2021-03-22 22-06-31](https://user-images.githubusercontent.com/3050060/112059815-a7005100-8b5c-11eb-9e40-8fc57513e498.png) r? ``@Nemo157``
2021-03-24Rollup merge of #83051 - GuillaumeGomez:sidebar-trait-items-order, ↵Dylan DPC-4/+4
r=CraftSpider,jyn514 Sidebar trait items order We were actually sorting `Symbol` and not `String`, creating a completely invalid sort result. I added a test to prevent regressions. r? ``@jyn514``
2021-03-23Auto merge of #82994 - camelid:rename-source-to-span, r=jyn514bors-43/+51
Rename `source` to `span` and `span` to `source` - Rename `clean::Item.source` to `span` - Rename `clean::Span::span()` to `clean::Span::inner()` - Rename `rustdoc_json_types::Item.source` to `span` - rustdoc-json: Rename `Import.span` to `Import.source` *See also the [discussion on Zulip][z] (this is a bit more than discussed in that conversation, but all the changes are related).* r? `@jyn514` [z]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/get.20span.20of.20file.20from.20name/near/229603729
2021-03-23Remove another unnecessary `Option`Camelid-13/+7
The previous changes mean that we can now remove this `Option`.
2021-03-23Remove unnecessary `Option` wrapping around `Crate.module`Camelid-72/+54
I'm wondering if it was originally there so that we could `take` the module which enables `after_krate` to take an `&Crate`. However, the two impls of `after_krate` only use `Crate.name`, so we can pass just the name instead.
2021-03-23Tweak docsCamelid-1/+3
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-03-23Use &str instead of StringGuillaume Gomez-3/+3
2021-03-23Fix sidebar trait items sortGuillaume Gomez-3/+3
2021-03-23Slight visual improvements to warning boxes in the docsr00ster91-4/+13
2021-03-22Don't push the crate name onto the `Cache.stack`Camelid-2/+0
Now that we record the crate's name in its `clean::Item`, pushing the crate name onto the `stack` causes duplicate paths. E.g., the URL generated for the path `::foo::bar::baz` would be something like ../foo/foo/bar/baz With this commit, the URL is corrected to ../foo/bar/baz
2021-03-22rustdoc: Record crate name instead of using `None`Camelid-1/+1
2021-03-23Rollup merge of #83389 - njasm:test_rustdoc, r=jyn514Yuki Okushi-0/+3
add rust-analyzer rustc_private option in librustdoc Cargo.toml This addition will allow to have code completion while hacking rustdoc with rust-analyzer. more info: https://rust-analyzer.github.io/manual.html#rust-analyzer.rustcSource r? `@jyn514`
2021-03-23Rollup merge of #83356 - camelid:rustdoc-option-to-enum, r=GuillaumeGomezYuki Okushi-8/+11
rustdoc: Replace pair of `Option`s with an enum They are never both `None` or both `Some`, so it makes more sense to use an enum so that we "make impossible states impossible".
2021-03-23Rollup merge of #82732 - GuillaumeGomez:remove-theme-file, r=Nemo157Yuki Okushi-74/+83
Remove theme.js file Fixes #82616. The first commit moves the `theme.js` file into `main.js`, which requires to also run a small `.replace` on the `main.js` content. The second commit is just a small cleanup to centralize DOM ids. Since it removes a file from rustdoc output: cc `@rust-lang/docs-rs` cc `@jsha` r? `@jyn514`
2021-03-23Rollup merge of #80705 - tspiteri:italic-and-update-SourceCodePro, ↵Yuki Okushi-9/+22
r=GuillaumeGomez Update Source Code Pro and include italics Fixes #65502. #65665, a similar PR to this was merged but reverted because of https://github.com/rust-lang/rust/pull/65665#issuecomment-556860510. The issue in that comment is the upstream issue https://github.com/adobe-fonts/source-code-pro/issues/217 which should now be fixed in the upstream since [2.032R-ro/1.052R-it/1.012R-VAR release](https://github.com/adobe-fonts/source-code-pro/releases/tag/2.032R-ro/1.052R-it/1.012R-VAR), so I think this can now be merged. A couple of notes from the original PR: * Since this PR changes the font set, I think docs.rs would have to be updated if this PR is merged. * The fonts have a double extension (.ttf.woff); this is to keep the names consistent with the upstream font release which does that to distinguish these from the .otf.woff files (Source Code Pro otf renders poorly on older Windows system apps).
2021-03-22Fix codeblock tooltip positionGuillaume Gomez-1/+1
2021-03-22Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakisbors-1/+1
Stabilize or_patterns (RFC 2535, 2530, 2175) closes #54883 This PR stabilizes the or_patterns feature in Rust 1.53. This is blocked on the following (in order): - [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021 - [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705) - It looks like we will need to pursue some sort of edition-based transition for `:pat`. - [x] Nomination and discussion by T-lang - [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100). - [ ] An FCP on stabilization EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22missing newline at eofNelson J Morais-1/+1
2021-03-22add key rustc_private for package metadata for rust-analyzer in librustdocNelson J Morais-0/+3
2021-03-22Auto merge of #82855 - jyn514:no-temporaries, r=GuillaumeGomezbors-18/+30
Avoid temporary allocations in `render_assoc_item` `render_assoc_item` came up as very hot in a profile of rustdoc on `bevy`. This avoids some temporary allocations just to calculate the length of the header. This should be a strict improvement, since all string formatting was done twice before. cc #82845
2021-03-21Remove redundant docsCamelid-5/+7
...and add docs to the types instead of the fields that hold the types.
2021-03-21Bump rustdoc-json format versionCamelid-1/+1
The rustdoc-json-types renames are breaking changes.
2021-03-21rustdoc-json: Rename `Import.span` to `Import.source`Camelid-2/+2
* It is called `source` in rustc and the rest of rustdoc * It is not a span, rather it is the source of the import
2021-03-21Rename `rustdoc_json_types::Item.source` to `span`Camelid-2/+2
2021-03-21Rename `clean::Span::span()` to `clean::Span::inner()`Camelid-13/+13
Otherwise you get a lot of instances of `item.span.span()`, which is just plain confusing. `item.span.inner()` conveys the correct meaning of "get the type that `clean::Span` wraps".
2021-03-21Rename `clean::Item.source` to `span`Camelid-34/+38
Its type is called `clean::Span`, and also the name in the rest of rustdoc and rustc for this kind of field is `span`.
2021-03-21rustdoc: Replace pair of `Option`s with an enumCamelid-8/+11
They are never both `None` or both `Some`, so it makes more sense to use an enum so that we "make impossible states impossible".
2021-03-20update `const_eval_resolve`lcnr-1/+1
2021-03-19librustdoc: or_patterns are stablemark-1/+1
2021-03-19Rollup merge of #79986 - GuillaumeGomez:build-help-when-needed, r=Nemo157Dylan DPC-12/+20
Only build help popup when it's really needed When working on https://github.com/rust-lang/rust/pull/79985, I realized that the help popup was built even when it wasn't needed. This PR only makes the help popup to be built when required. r? `@jyn514`
2021-03-19Ignore main.js file lengthGuillaume Gomez-0/+1
2021-03-19Only build help popup when it's really neededGuillaume Gomez-12/+19
2021-03-19Rollup merge of #82846 - GuillaumeGomez:doc-alias-list, r=jyn514Dylan DPC-6/+17
rustdoc: allow list syntax for #[doc(alias)] attributes Fixes https://github.com/rust-lang/rust/issues/81205. It now allows to have: ```rust #[doc(alias = "x")] // and: #[doc(alias("y", "z"))] ``` cc ``@jplatte`` r? ``@jyn514``
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-1/+1
2021-03-17Auto merge of #83188 - petrochenkov:field, r=lcnrbors-3/+3
ast/hir: Rename field-related structures I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent. - `StructField` -> `FieldDef` ("field definition") - `Field` -> `ExprField` ("expression field", not "field expression") - `FieldPat` -> `PatField` ("pattern field", not "field pattern") Various visiting and other methods working with the fields are renamed correspondingly too. The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17Rollup merge of #83203 - jyn514:rustdoc-warnings, r=ManishearthYuki Okushi-1/+1
Don't warn about old rustdoc lint names (temporarily) Since https://github.com/rust-lang/rust/pull/80527, rustdoc users have an unpleasant situation: they can either use the new tool lint names (`rustdoc::non_autolinks`) or they can use the old names (`non_autolinks`). If they use the tool lints, they get a hard error on stable compilers, because rustc rejects all tool names it doesn't recognize (https://github.com/rust-lang/rust/issues/66079#issuecomment-788589193). If they use the old name, they get a warning to rename the lint to the new name. The only way to compile without warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the whole point of the change: we *want* people to switch to the new name. To avoid people silencing the lint and never migrating to the tool lint, this avoids warning about the old name, while still allowing you to use the new name. Once the new `rustdoc` tool name makes it to the stable channel, we can change these lints to warn again. This adds the new lint functions `register_alias` and `register_ignored` - I didn't see an existing way to do this. r? `@Manishearth` cc `@rust-lang/rustdoc`
2021-03-16Don't warn about old rustdoc lint names (temporarily)Joshua Nelson-1/+1
Right now, rustdoc users have an unpleasant situation: they can either use the new tool lint names (`rustdoc::non_autolinks`) or they can use the old names (`non_autolinks`). If they use the tool lints, they get a hard error on stable compilers, because rustc rejects all tool names it doesn't recognize. If they use the old name, they get a warning to rename the lint to the new name. The only way to compile without warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the whole point of the change: we *want* people to switch to the new name. To avoid people silencing the lint and never migrating to the tool lint, this avoids warning about the old name, while still allowing you to use the new name. Once the new `rustdoc` tool name makes it to the stable channel, we can change these lints to warn again. This adds the new lint functions `register_alias` and `register_ignored` - I didn't see an existing way to do this.
2021-03-16Rollup merge of #83157 - nagisa:nagisa/portability-background, r=GuillaumeGomezYuki Okushi-9/+3
No background for code in portability snippets This better matches the appearance of this kind of snippet in the full item view and is less jarring to read due to repeated foreground-background changes. ![Listing of items in a module with some portability snippets attached to some of the items (light theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196363-1900f500-85b5-11eb-8f97-e283c59002a4.png) ![Listing of items in a module with some portability snippets attached to some of the items (dark theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196366-19998b80-85b5-11eb-9914-4d14d9d13ed3.png) There should be no observable changes to the ayu theme.
2021-03-16Rollup merge of #83156 - nagisa:nagisa/sans-serif-please, r=GuillaumeGomezYuki Okushi-4/+5
Fall-back to sans-serif if Arial is not available Otherwise on systems where Arial is not available the UA will fallback to a serif font, rather than a sans-serif one. This is especially relevant on acessibility-conscious setups (such as is mine) that have web-fonts disabled and a limited set of fonts available on the system. r? ```@GuillaumeGomez``` cc ```@jsha```
2021-03-16Rollup merge of #83077 - notriddle:gc-cleanup-rustdoc-search, r=GuillaumeGomezYuki Okushi-49/+78
rustdoc: reduce GC work during search