about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2021-10-08Rollup merge of #89538 - notriddle:notriddle/arrow-highlight, r=GuillaumeGomezGuillaume Gomez-12/+6
Make rustdoc not highlight `->` and `=>` as operators It was marking them up as `<span class="op">=</span><span class="op">&gt;</span>`, which is bloaty and wrong (at least, I think `<=` and `=>` should probably be different colors, since they're so different and yet made from the same symbols). Before: ![image](https://user-images.githubusercontent.com/1593513/135939748-f49b0f9e-6a7d-4d65-935a-e31cdf688a81.png) After: ![image](https://user-images.githubusercontent.com/1593513/135940063-5ef1f6b1-7e03-4227-b46b-572b063aba05.png)
2021-10-07Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514Guillaume Gomez-0/+70
Make cfg imply doc(cfg) This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well): * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc. * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation. * I updated the version for the feature. There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624) > I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different. How/why should they differ? EDIT: this part has been solved, the current code was fine, just needed a little simplification. cc `@Nemo157` r? `@jyn514` Original PR description: This is only active when the `doc_cfg` feature is active. The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like: ```rust #[cfg(unix)] #[doc(cfg(all()))] pub struct Unix; ``` By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-05Allow adding a set of cfg's to hide from being implicitly doc(cfg)'dWim Looman-0/+32
By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg #[cfg(foobar)] (and _only_ that _exact_ cfg) will not be implicitly treated as a doc(cfg) to render a message in the documentation.
2021-10-05Make cfg implicitly imply doc(cfg)Wim Looman-0/+38
This is only active when the `doc_cfg` feature is active. The implicit cfg can be overridden via #[doc(cfg(...))], so e.g. to hide a #[cfg] you can use something like: ```rust #[cfg(unix)] #[doc(cfg(all()))] pub struct Unix; ``` (since `all()` is always true, it is never shown in the docs)
2021-10-04Add tests for ensuring docblock headings.Mukund Lakshman-0/+29
2021-10-04Fix rustdoc test caseMichael Howell-12/+6
2021-10-04librustdoc: Use correct heading levels.Mukund Lakshman-8/+8
- Avoid multiple <h1>s on a page. - The <h#> tags should follow a semantic hierarchy. - Cap at h6 (no h7)
2021-09-25Rollup merge of #89198 - hkmatsumoto:hide-hidden-methods, r=jyn514Manish Goregaokar-0/+60
rustdoc: Don't show hidden trait methods Fix #89186. By skipping trait items whose attributes include `hidden`, we avoid showing such trait methods.
2021-09-25rustdoc: Don't show hidden trait methodsHirochika Matsumoto-0/+60
By skipping trait items whose attributes include `hidden`, we void showing such trait methods.
2021-09-24Disable a spuriously failing testVadim Petrochenkov-0/+2
2021-09-22Run no_core rustdoc tests on Linux only.Hans Kratz-2/+2
Windows on Macos ARM64 produce linker errors.
2021-09-13Add test for primitive in "jump to definition" featureGuillaume Gomez-1/+24
2021-09-12Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514Manish Goregaokar-1/+1
rustdoc: Cleanup `clean` part 1 Split out from #88379. These commits are completely independent of each other, and each is a fairly small change (the last few are new commits; they are not from #88379): - Remove unnecessary `Cache.*_did` fields - rustdoc: Get symbol for `TyParam` directly - Create a valid `Res` in `external_path()` - Remove unused `hir_id` parameter from `resolve_type` - Fix redundant arguments in `external_path()` - Remove unnecessary `is_trait` argument - rustdoc: Cleanup a pattern match in `external_generic_args()` r? ``@jyn514``
2021-09-12Fix `no_core` and `no_std` rustdoc tests on WindowsGuillaume Gomez-1/+4
This prevents the following (very strange) errors: ``` error: linking with `link.exe` failed: exit code: 1120 | = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86\\link.exe" "/DEF:C:\\Users\\runneradmin\\AppData\\Local\\Temp\\rustcJih4fa\\lib.def" "/NOLOGO" "/LARGEADDRESSAWARE" "/SAFESEH" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.issue_15318.0a2a8554-cgu.0.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.1na9aylmt25n6w3f.rcgu.o" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\native\\rust-test-helpers" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "vcruntime.lib" "ucrt.lib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-78744e1360284b1e.rlib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-a900fa3d16956226.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-eb97e6b4dfd2f421.rlib" "/NXCOMPAT" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "/OUT:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll.lib" "/DEBUG" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libstd.natvis" = note: LINK : warning LNK4216: Exported entry point __DllMainCRTStartup@12 Creating library D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.lib and object D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.exp libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aulldiv referenced in function __ZN4core3num7dec2flt7decimal7Decimal10left_shift17hfb9b6c23d6ff0383E libcompiler_builtins-eb97e6b4dfd2f421.rlib(compiler_builtins-eb97e6b4dfd2f421.compiler_builtins.a5ef280a-cgu.51.rcgu.o) : error LNK2001: unresolved external symbol __aulldiv libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aullrem referenced in function __ZN4core3fmt3num14parse_u64_into17h90eb20517ec3bd86E D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll : fatal error LNK1120: 2 unresolved externals ```
2021-09-12Fix linkcheck issuesJoshua Nelson-0/+10
Most of these are because alloc uses `#[lang_item]` to define methods, but core documents primitives before those methods are available. - Fix rustdoc-js-std test For some reason this change made CStr not show up in the results for `str,u8`. Since it still shows up for str, and since it wasn't a great match for that query anyway, I think this is ok to let slide. - Add test that all primitives can be linked to - Enable `doc(primitive)` in `core` as well - Add linkcheck exception specifically for Windows Ideally this would be done automatically by the linkchecker by replacing `\\` with forward slashes, but this PR is already a ton of work ... - Don't forcibly fail linkchecking if there's a broken intra-doc link on Windows Previously, it would exit with a hard error if a missing file had `::` in it. This changes it to report a missing file instead, which allows adding an exception.
2021-09-12Fix broken handling of primitive itemsJoshua Nelson-8/+43
- Fix broken handling of primitive associated items - Remove fragment hack Fixes 83083 - more logging - Update CrateNum hacks The CrateNum has no relation to where in the dependency tree the crate is, only when it's loaded. Explicitly special-case core instead of assuming it will be the first DefId. - Update and add tests - Cache calculation of primitive locations This could possibly be avoided by passing a Cache into collect_intra_doc_links; but that's a much larger change, and doesn't seem valuable other than for this.
2021-09-12Add primitive documentation to libcoreJoshua Nelson-2/+12
This works by doing two things: - Adding links that are specific to the crate. Since not all primitive items are defined in `core` (due to lang_items), these need to use relative links and not intra-doc links. - Duplicating `primitive_docs` in both core and std. This allows not needing CARGO_PKG_NAME to build the standard library. It also adds a tidy check to make sure they stay the same.
2021-09-11Create a valid `Res` in `external_path()`Noah Lev-1/+1
The order of the `where` bounds on auto trait impls changed because rustdoc currently sorts auto trait `where` bounds based on the `Debug` output for the bound. Now that the bounds have an actual `Res`, they are being unintentionally sorted by their `DefId` rather than their path. So, I had to update a test for the change in ordering of the rendered bounds.
2021-09-10Rollup merge of #88742 - GuillaumeGomez:fix-table-in-docblocks, r=nbdd0121Manish Goregaokar-0/+16
Fix table in docblocks "Overwrite" of #88702. Instead of adding a z-index to the sidebar (which only hides the issue, doesn't fix it), I wrap `<table>` elements inside a `<div>` and limit all chidren of `.docblock` elements' width to prevent having the scrollbar on the whole doc block. ![Screenshot from 2021-09-08 15-11-24](https://user-images.githubusercontent.com/3050060/132515740-71796515-e74f-429f-ba98-2596bdbf781c.png) Thanks `@nbdd0121` for `overflow-x: auto;`. ;) r? `@notriddle`
2021-09-10Rollup merge of #88639 - Emilgardis:fix-issue-88600, r=GuillaumeGomezManish Goregaokar-0/+34
rustdoc: Fix ICE with `doc(hidden)` on tuple variant fields Fixes #88600. ```rust pub struct H; pub struct S; pub enum FooEnum { HiddenTupleItem(#[doc(hidden)] H), MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H), MixedHiddenFirst(#[doc(hidden)] H, S), MixedHiddenLast(S, #[doc(hidden)] H), HiddenStruct { #[doc(hidden)] h: H, s: S, }, } ``` Generates ![image](https://user-images.githubusercontent.com/1502855/132259152-382f9517-c2a0-41d8-acd0-64e5993931fc.png)
2021-09-08Rollup merge of #86263 - fee1-dead:rustdoc-layout-variants, r=camelidJack Huey-0/+18
Rustdoc: Report Layout of enum variants Followup of #83501, Fixes #86253. cc `@camelid` `@rustbot` label A-rustdoc
2021-09-08Add tests to ensure that <table> don't break doc blocks width anymoreGuillaume Gomez-0/+16
2021-09-06fix ICE on hidden tuple variant fieldsEmil Gardström-0/+34
this also renders them as `_`, which rustdoc previously did not.
2021-09-06Correctly handle niche of enumDeadbeef-0/+9
2021-09-01Auto merge of #88490 - GuillaumeGomez:associated-types-implementors-display, ↵bors-1/+10
r=camelid,Manishearth Display associated types of implementors Fixes #86631. Contrary to before, it doesn't display methods. I also had to "resurrect" the `auto-hide-trait-implementations` setting. :3 Only question at this point: should I move the `render_impl` boolean arguments into one struct? We're starting to have quite a lot of them... cc `@cynecx` r? `@camelid`
2021-09-01Add tests for implementors associated types displayGuillaume Gomez-1/+10
2021-08-31Apply suggestionsDeadbeef-1/+3
2021-08-31Report variant size without the discriminantDeadbeef-1/+2
2021-08-31Report Layout of enum variantsDeadbeef-0/+6
Followup of #83501, Fixes #86253.
2021-08-30`feature(const_param_types)` -> `feature(adt_const_params)`lcnr-1/+1
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-5/+3
2021-08-30remove lazy_normalization_constsEllen-1/+1
2021-08-30rename const_evaluatable_checked to generic_const_exprsEllen-1/+1
:sparkles:
2021-08-29Add regression testinquisitivecrystal-0/+19
2021-08-28Update testsinquisitivecrystal-0/+58
2021-08-26Rollup merge of #88215 - jyn514:lazy-loading, r=petrochenkovManish Goregaokar-4/+10
Reland #83738: "rustdoc: Don't load all extern crates unconditionally" I hopefully found all the bugs :crossed_fingers: time for a take two. See the last commit for details on what went wrong before. r? `@petrochenkov` (but feel free to reassign to Guillaume if you don't have time.) Closes https://github.com/rust-lang/rust/issues/68427. Includes a fix for https://github.com/rust-lang/rust/issues/84738.
2021-08-26Fix the bugs and add a regression testJoshua Nelson-0/+8
- All attributes for an item need to be considered at once, they can't be considered a line at a time. - The top-level crate was not being visited. This bug was caught by `extern-crate-used-only-in-link`, which I'm very glad I added. - Make the loader private to the module, so that only one function is exposed.
2021-08-22Revert "Revert "Don't load all extern crates unconditionally""Joshua Nelson-4/+2
This reverts commit 5f0c54db4e595a6a77048f2b0605138ffa49a326.
2021-08-19Give precedence to `html_root_url` over `--extern-html-root-url` by default, ↵Joshua Nelson-3/+25
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-05Fix URL conflict for std typeGuillaume Gomez-1/+1
2021-08-05Add missing root_path when generating links using hrefGuillaume Gomez-3/+9
2021-08-05Generate links for modules as wellGuillaume Gomez-4/+5
2021-08-05Add test for source code pages URLsGuillaume Gomez-0/+55
2021-07-29Rollup merge of #87451 - GuillaumeGomez:tuple-struct-field-doc, r=jyn514Yuki Okushi-2/+38
Add support for tuple struct field documentation Fixes #42615. This is #80320 updated to new codebase and with added tests. Part of https://github.com/rust-lang/rust/issues/83255. cc ```@camelid``` (since you were involved on the original PR). r? ```@jyn514```
2021-07-27Make all tests use type_alias_impl_trait feature instead of minSantiago Pastorino-3/+3
2021-07-26Add test for enum item tuple fields documentationGuillaume Gomez-2/+19
2021-07-25Auto merge of #87390 - notriddle:notriddle/rustdoc-headers-patch, ↵bors-191/+191
r=GuillaumeGomez Rustdoc accessibility: use real headers for doc items Part of #87059 Partially reverts #84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
2021-07-25Rustdoc accessibility: use real headers for doc itemsbors-191/+191
Part of #87059 Partially reverts #84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
2021-07-25Add test for tuple struct documentation fieldsGuillaume Gomez-0/+19
2021-07-22Don't hide fields of enum struct variantsNoah Lev-4/+2
* The toggle adds visual clutter * It's easy to miss that there are fields * Tuple variant fields are always shown, so it is inconsistent to hide struct variant fields * It's annoying to have to click the toggle every time