about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2021-08-24Stabilize `force-warn`inquisitivecrystal-3/+2
2021-08-24Tidy up lint command line flagsinquisitivecrystal-12/+5
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-21Auto merge of #82776 - jyn514:extern-url-fallback, r=GuillaumeGomezbors-11/+26
Give precedence to `html_root_url` over `--extern-html-root-url` by default, but add a way to opt-in to the previous behavior ## What is an HTML root url? It tells rustdoc where it should link when documentation for a crate is not available locally; for example, when a crate is a dependency of a crate documented with `cargo doc --no-deps`. ## What is the difference between `html_root_url` and `--extern-html-root-url`? Both of these tell rustdoc what the HTML root should be set to. `doc(html_root_url)` is set by the crate author, while `--extern-html-root-url` is set by the person documenting the crate. These are often different. For example, docs.rs uses `--extern-html-root-url https://docs.rs/crate-name/version` to ensure all crates have documentation, even if `html_root_url` is not set. Conversely, crates such as Rocket set `doc(html_root_url = "https://api.rocket.rs")`, because they prefer users to view the documentation on their own site. Crates also set `html_root_url` to ensure they have documentation when building locally when offline. This is unfortunate to require, because it's more work from the library author. It also makes it impossible to distinguish between crates that want to be viewed on a different site (e.g. Rocket) and crates that just want documentation to be visible offline at all (e.g. Tokio). I have authored a separate change to the API guidelines to no longer recommend doing this: rust-lang/api-guidelines#230. ## Why change the default? In the past, docs.rs has been the main user of `--extern-html-root-url`. However, it's useful for other projects as well. In particular, Cargo wants to pass it by default when running `--no-deps` (rust-lang/cargo#8296). Unfortunately, for these other use cases, the priority order is inverted. They want to give *precedence* to the URL the crate picks, and only fall back to the `--extern-html-root` if no `html_root_url` is present. That allows passing `--extern-html-root` unconditionally, without having to parse the source code to see what attributes are present. For docs.rs, however, we still want to keep the old behavior, so that all links on docs.rs stay on the site.
2021-08-21Auto merge of #88149 - Mark-Simulacrum:prep-never-type, r=jackh726bors-0/+1
Refactor fallback code to prepare for never type This PR contains cherry-picks of some of `@nikomatsakis's` work from #79366, and shouldn't (AFAICT) represent any change in behavior. However, the refactoring is good regardless of the never type work being landed, and will reduce the size of those eventual PR(s) (and rebase pain). I am not personally an expert on this code, and the commits are essentially 100% `@nikomatsakis's,` but they do seem reasonable to me by my understanding. Happy to edit with review, of course. Commits are best reviewed in sequence rather than all together. r? `@jackh726` perhaps?
2021-08-19introduce a Coerce predicateNiko Matsakis-0/+1
2021-08-19Rollup merge of #88093 - Kobzol:rustdoc-wrap-code-in-code-tag, r=GuillaumeGomezGuillaume Gomez-266/+294
[rustdoc] Wrap code blocks in <code> tag This PR modifies Rustdoc output so that fenced code snippets, items and whole file source codes are wrapped in `<pre><code>` instead of just `<pre>`. This should improve the semantic meaning of the generated content. I'm not sure what to do about `render_attributes_in_pre` and `render_attributes_in_code`. These functions were clearly expected to be used for things inside `<pre>` or `<code>`, and since I added `<code>` in this PR, some of them will be used in a different context than before. However, it seems to me that even before they were not consistent. For example, `item_constant` used `render_attributes_in_code` for its attributes, however there was no `<code>` used for constants before this PR... Should I create some `rustdoc-gui` tests? For example to check that all `<pre>` tags have a `<code>` child? Fixes: https://github.com/rust-lang/rust/issues/88020
2021-08-19[rustdoc] Wrap code blocks in <code> tagJakub Beránek-266/+294
2021-08-19Give precedence to `html_root_url` over `--extern-html-root-url` by default, ↵Joshua Nelson-11/+26
but add a way to opt-in to the previous behavior ## What is an HTML root url? It tells rustdoc where it should link when documentation for a crate is not available locally; for example, when a crate is a dependency of a crate documented with `cargo doc --no-deps`. ## What is the difference between `html_root_url` and `--extern-html-root-url`? Both of these tell rustdoc what the HTML root should be set to. `doc(html_root_url)` is set by the crate author, while `--extern-html-root-url` is set by the person documenting the crate. These are often different. For example, docs.rs uses `--extern-html-root-url https://docs.rs/crate-name/version` to ensure all crates have documentation, even if `html_root_url` is not set. Conversely, crates such as Rocket set `doc(html_root_url = "https://api.rocket.rs")`, because they prefer users to view the documentation on their own site. Crates also set `html_root_url` to ensure they have documentation when building locally when offline. This is unfortunate to require, because it's more work from the library author. It also makes it impossible to distinguish between crates that want to be viewed on a different site (e.g. Rocket) and crates that just want documentation to be visible offline at all (e.g. Tokio). I have authored a separate change to the API guidelines to no longer recommend doing this: https://github.com/rust-lang/api-guidelines/pull/230. ## Why change the default? In the past, docs.rs has been the main user of `--extern-html-root-url`. However, it's useful for other projects as well. In particular, Cargo wants to pass it by default when running `--no-deps` (https://github.com/rust-lang/cargo/issues/8296). Unfortunately, for these other use cases, the priority order is inverted. They want to give *precedence* to the URL the crate picks, and only fall back to the `--extern-html-root` if no `html_root_url` is present. That allows passing `--extern-html-root` unconditionally, without having to parse the source code to see what attributes are present. For docs.rs, however, we still want to keep the old behavior, so that all links on docs.rs stay on the site.
2021-08-19Auto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelidbors-5/+9
Fix anchors display in rustdoc Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background). ![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png) ![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png) ![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png) r? `@camelid`
2021-08-18Rollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhprattGuillaume Gomez-0/+9
Add background-color on clickable definitions in source code Someone suggested to add a decoration on clickable elements in the source code pages: ![Screenshot from 2021-08-17 14-49-39](https://user-images.githubusercontent.com/3050060/129728911-def74f9e-50e2-40d2-b512-e23f1b3d0409.png) ![Screenshot from 2021-08-17 14-49-47](https://user-images.githubusercontent.com/3050060/129728925-14aec500-82ff-4336-955a-4173c769deeb.png) ![Screenshot from 2021-08-17 14-49-52](https://user-images.githubusercontent.com/3050060/129728927-a8a89d7a-e837-4ff5-b094-35be23629d14.png) The idea is to not disturb the reading while telling the reader "you can click on this one", which is why it's not a text decoration. What do you think `@rust-lang/rustdoc` ? r? `@Nemo157`
2021-08-18Rollup merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelidGuillaume Gomez-5/+9
Fix anchors display in rustdoc Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background). ![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png) ![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png) ![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png) r? `@camelid`
2021-08-18Fix anchors display in rustdocGuillaume Gomez-5/+9
2021-08-18remove box_syntax uses from cranelift and toolsMarcel Hellwig-47/+54
2021-08-17Add background-color on clickable definitions in source codeGuillaume Gomez-0/+9
2021-08-16Rollup merge of #87178 - moxian:rd-use, r=jyn514Mara Bos-4/+3
[rustdoc] Copy only item path to clipboard rather than full `use` statement. The (somewhat) recent addition of the "copy item import to clipboard" button is extremely nice. However, i tend to write my code with fully qualified paths wherever feasible and only resort to `use` statements as a refactoring pass. This makes the "copy to clipboard" workflow awkward to use, as i would be copy-pasting that as, say ```rust impl use std::ops::Add; for MyType { ``` and then go back and remove the `use ` and `;`. This PR removes the `use ;` decorations, making it much nicer to use for fully-qualified items. I argue, however, that this does not noticeably degrade experience for those who prefer to import items, since the hard part about those is getting the path right, and writing the `use ;` decoration can be done by hand with little effort.
2021-08-14Auto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obkbors-8/+6
Try filtering out non-const impls when we expect const impls **TL;DR**: Associated types on const impls are now bounded; we now disallow calling a const function with bounds when the specified type param only has a non-const impl. r? `@oli-obk`
2021-08-13move Constness into TraitPredicateDeadbeef-8/+6
2021-08-12Updates favicon order of precedence as it matters to Chromeskim-2/+2
2021-08-08Fix heading colours in Ayu themeKlim Tsoutsman-1/+1
Closes #87828 The issue seems to stem from #87210 where code headings were changed from a heading containing code to a heading with the `code-header` class. `rustdoc.css` was updated, but `ayu.css` was missed.
2021-08-08Rollup merge of #87834 - camelid:span-typo, r=CraftSpiderYuki Okushi-1/+1
Fix small typo The closing backtick was outside the closing bracket, which is why the intra-doc link wasn't working.
2021-08-06Fix small typoNoah Lev-1/+1
The closing backtick was outside the closing bracket, which is why the intra-doc link wasn't working.
2021-08-05Remove LightSpan and use Span directlyGuillaume Gomez-98/+44
2021-08-05Remove warnings/errors from compiler when using typeck_body in rustdoc span ↵Guillaume Gomez-5/+5
map builder
2021-08-05* Rename LightSpan::empty into LightSpan::dummyGuillaume Gomez-23/+19
* Add Classifier::new_light_span to wrap LightSpan::new_in_file constructor
2021-08-05Add missing root_path when generating links using hrefGuillaume Gomez-2/+26
2021-08-05Add documentation and FIXMEGuillaume Gomez-4/+7
2021-08-05Fix invalid generation of HTML in highlightGuillaume Gomez-41/+60
2021-08-05formattingGuillaume Gomez-30/+19
2021-08-05Use rustdoc Span in LinkFromSrc directlyGuillaume Gomez-15/+6
2021-08-05Move extra arguments for highlight URL generation into a new ContextInfo ↵Guillaume Gomez-40/+42
struct for better readability
2021-08-05Wrap the span_map tuple index into a type called "LightSpan"Guillaume Gomez-44/+68
2021-08-05Improve code readabilityGuillaume Gomez-57/+46
2021-08-05* Rename Span::from_rustc_span to Span::newGuillaume Gomez-9/+10
* Rename Span::wrap to Span::wrap_raw * Improve documentation for Span::wrap_raw
2021-08-05* Rename 'move_span' into 'local_span_to_global_span'Guillaume Gomez-17/+85
* Add documentation on new arguments/functions
2021-08-05Underline source code links on hoverGuillaume Gomez-0/+4
2021-08-05Update rustdoc testsGuillaume Gomez-3/+3
2021-08-05Generate links for modules as wellGuillaume Gomez-5/+24
2021-08-05Generate links for methods as wellGuillaume Gomez-19/+39
2021-08-05Ensure that --generate-link-to-definition is only used with HTML output and ↵Guillaume Gomez-0/+8
is unstable
2021-08-05Add an option for the source code link generationGuillaume Gomez-3/+23
2021-08-05Add links on source types to go to definitionGuillaume Gomez-106/+454
2021-08-04Auto merge of #87568 - petrochenkov:localevel, r=cjgillotbors-13/+3
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables and passes using those tables - primarily privacy checking, stability checking and dead code checking. All these passes work with definitions rather than with arbitrary HIR nodes. r? `@cjgillot` cc `@lambinoo` (#87487)
2021-08-04Rollup merge of #87720 - matthiaskrgr:clippy_into, r=jyn514Yuki Okushi-19/+18
don't use .into() to convert types to identical types (clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-08-03Simplify usage of CSS background-imageGuillaume Gomez-24/+57
2021-08-03Use empty string instead of single spaceMichael Howell-2/+2
2021-08-03Pull the "Expand" / "Collapse" text to the end of the line, instead of startMichael Howell-7/+17
2021-08-03Rustdoc accessibility: use an icon for the [-]/[+] controlsMichael Howell-8/+69
This way, we can show the plus and minus buttons on screens, while voice control will read off actual words "Collapse" and "Expand" instead of reading "open brace minus close brace" and "open brace plus close brace". Part of #87059
2021-08-03don't use .into() to convert types to identical types ↵Matthias Krüger-19/+18
(clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();