summary refs log tree commit diff
path: root/src/librustdoc/html/render/write_shared.rs
AgeCommit message (Collapse)AuthorLines
2025-03-03Rollup merge of #137684 - GuillaumeGomez:rustdoc-dep-info, r=notriddleMatthias Krüger-1/+1
Add rustdoc support for `--emit=dep-info[=path]` Fixes #91982. This PR adds the `--emit=dep-info` command line flag support. It will be helpful for `cargo` development. cc ````@epage```` r? ````@notriddle````
2025-02-26Use helper function instead of reimplementing the logic to check if rustdoc ↵Guillaume Gomez-1/+1
should emit crate
2025-02-23return `impl fmt::Display` in more places instead of writing to stringsYotam Ofek-20/+16
2025-02-12Nuke `Buffer` abstraction from `librustdoc` 💣Yotam Ofek-19/+20
2025-01-29rustdoc: run css and html minifier at build instead of runtimeMichael Howell-8/+2
This way, adding a bunch of comments to the JS files won't make rustdoc slower.
2025-01-11re-add --disable-minification to rustdocbinarycat-1/+9
this also makes the rust.docs-minification option work as advertised in config.toml nothing fancy this time, this is intended to be perma-unstable. it's only really here for the benefit of rustdoc devs. mitegates https://github.com/rust-lang/rust/issues/135345
2024-12-01Move `SharedContext` out of `Rc`Guillaume Gomez-14/+9
2024-12-01Stop cloning `Context` so muchGuillaume Gomez-1/+1
2024-11-28Fix new clippy lintsGuillaume Gomez-29/+27
2024-10-19rustdoc: Document `markdown` module.Alona Enraght-Moony-1/+1
Rustdoc markdown handling is currently split between: - html::markdown, which contains all the meaty login - markdown, which is only used for when rustdoc renders a standalone markdown file Adds module-level doc-comment to markdown, and rename the function so it's clear that it's doing IO (instead of just rendering to a string).
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-5/+5
2024-09-25don't clone `clean::Item` in `TypeImplCollector`Lukas Markeffsky-9/+9
2024-09-25rm higher-ranked lifetimes from `DocVisitor`Lukas Markeffsky-1/+1
This allows the visitor to borrow from the visitees.
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-3/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-09-10Auto merge of #129337 - EtomicBomb:rfc, r=notriddlebors-43/+135
rustdoc rfc#3662 changes under unstable flags * All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * `tests/rustdoc/` tests for the new flags
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-1/+1
2024-09-07rfc#3662 changes under unstable flagsEtomicBomb-43/+135
* All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * update tests/run-make/rustdoc-default-output/rmake.rs golden
2024-09-06Auto merge of #128776 - Bryanskiy:deep-reject-ctxt, r=lcnrbors-2/+2
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates The description is on the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/.5Basking.20for.20help.5D.20.60DeepRejectCtxt.60.20for.20param.20env.20candidates) r? `@lcnr`
2024-09-02Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidatesBryanskiy-2/+2
2024-08-26rustdoc: fix missing resource suffix on `crates.js`Michael Howell-6/+12
Fixes a regression introduced in #128252.
2024-08-08fix typos, more SelfEtomicBomb-2/+2
typos in comments, remove references to crate-info, Self type in ordered_json and sorted_template
2024-08-07rename sortedjson -> orderedjsonEtomicBomb-66/+75
2024-08-07added unit tests for write_sharedEtomicBomb-51/+48
2024-08-07initial implementation of mergable rustdoc cciEtomicBomb-655/+807
2024-06-30Uplift fast rejection to new solverMichael Goulet-2/+1
2024-03-16rustdoc-search: shard the search result descriptionsMichael Howell-2/+29
The descriptions are, on almost all crates[^1], the majority of the size of the search index, even though they aren't really used for searching. This makes it relatively easy to separate them into their own files. This commit also bumps us to ES8. Out of the browsers we support, all of them support async functions according to caniuse. https://caniuse.com/async-functions [^1]: <https://microsoft.github.io/windows-docs-rs/>, a crate with 44MiB of pure names and no descriptions for them, is an outlier and should not be counted.
2024-02-04rustdoc: trait.impl, type.impl: sort impls to make it not depend on ↵klensy-10/+21
serialization order
2023-12-15Simplify JS code a little bitGuillaume Gomez-2/+2
2023-12-14rustdoc-search: fix a race condition in search index loadingMichael Howell-2/+8
`var` declare it in the global scope, and `const` does not. It needs to be declared in global scope.
2023-12-14Use Map instead of Object for source files and search indexGuillaume Gomez-9/+10
2023-11-29rustdoc: Move `AssocItemRender` and `RenderMode` to `html::render`.Alona Enraght-Moony-2/+2
They're only used for HTML, so it makes more sense for them to live their.
2023-11-08rustdoc: minor changes suggested by clippy perf lints.Nicholas Nethercote-9/+6
2023-10-22rustdoc: make JS trait impls act more like HTMLMichael Howell-2/+19
2023-10-22rustdoc: use JS to inline target type impl docs into aliasMichael Howell-2/+250
This is an attempt to balance three problems, each of which would be violated by a simpler implementation: - A type alias should show all the `impl` blocks for the target type, and vice versa, if they're applicable. If nothing was done, and rustdoc continues to match them up in HIR, this would not work. - Copying the target type's docs into its aliases' HTML pages directly causes far too much redundant HTML text to be generated when a crate has large numbers of methods and large numbers of type aliases. - Using JavaScript exclusively for type alias impl docs would be a functional regression, and could make some docs very hard to find for non-JS readers. - Making sure that only applicable docs are show in the resulting page requires a type checkers. Do not reimplement the type checker in JavaScript. So, to make it work, rustdoc stashes these type-alias-inlined docs in a JSONP "database-lite". The file is generated in `write_shared.rs`, included in a `<script>` tag added in `print_item.rs`, and `main.js` takes care of patching the additional docs into the DOM. The format of `trait.impl` and `type.impl` JS files are superficially similar. Each line, except the JSONP wrapper itself, belongs to a crate, and they are otherwise separate (rustdoc should be idempotent). The "meat" of the file is HTML strings, so the frontend code is very simple. Links are relative to the doc root, though, so the frontend needs to fix that up, and inlined docs can reuse these files. However, there are a few differences, caused by the sophisticated features that type aliases have. Consider this crate graph: ```text --------------------------------- | crate A: struct Foo<T> | | type Bar = Foo<i32> | | impl X for Foo<i8> | | impl Y for Foo<i32> | --------------------------------- | ---------------------------------- | crate B: type Baz = A::Foo<i8> | | type Xyy = A::Foo<i8> | | impl Z for Xyy | ---------------------------------- ``` The type.impl/A/struct.Foo.js JS file has a structure kinda like this: ```js JSONP({ "A": [["impl Y for Foo<i32>", "Y", "A::Bar"]], "B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]], }); ``` When the type.impl file is loaded, only the current crate's docs are actually used. The main reason to bundle them together is that there's enough duplication in them for DEFLATE to remove the redundancy. The contents of a crate are a list of impl blocks, themselves represented as lists. The first item in the sublist is the HTML block, the second item is the name of the trait (which goes in the sidebar), and all others are the names of type aliases that successfully match. This way: - There's no need to generate these files for types that have no aliases in the current crate. If a dependent crate makes a type alias, it'll take care of generating its own docs. - There's no need to reimplement parts of the type checker in JavaScript. The Rust backend does the checking, and includes its results in the file. - Docs defined directly on the type alias are dropped directly in the HTML by `render_assoc_items`, and are accessible without JavaScript. The JSONP file will not list impl items that are known to be part of the main HTML file already. [JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-22rustdoc: rename `/implementors` to `/impl.trait`Michael Howell-1/+1
This is shorter, avoids potential conflicts with a crate named `implementors`[^1], and will be less confusing when JS include files are added for type aliases. [^1]: AFAIK, this couldn't actually cause any problems right now, but it's simpler just to make it impossible than relying on never having a file named `trait.Foo.js` in the crate data area.
2023-10-08rustdoc: clean up the In [name] up-pointerMichael Howell-1/+1
This commit makes three changes for consistency and readability: - It shows the sibling navigation on module pages. It's weird that it didn't work before, and is inconsistent with everything else (even Crates have sibling navigation with other Crates). - It hides the "In [parent]" header if it's the same as the current crate, and if there's no other header between them. We need to keep it on modules and types, since they have their own header and data between them, and we don't want to show siblings under a header implying that they're children. - It adds a margin to deal with the headers butting directly into the branding lockup.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+1
2023-08-16Use more named format argsGuillaume Gomez-3/+3
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-10/+9
2023-07-14rustdoc: use `src` consistently over `source` in JavaScriptMichael Howell-4/+4
Since the directory that contains source files is called `src`, it makes sense to name the scripts that way, too.
2023-02-02Auto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, ↵bors-1/+1
r=notriddle,petrochenkov Fix handling of items inside a `doc(hidden)` block Fixes #106373. cc `@aDotInTheVoid` r? `@notriddle`
2023-01-30rustdoc: remove meta keywords from HTMLMichael Howell-2/+1
Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-27Improve code readabilityGuillaume Gomez-1/+1
2023-01-19Revert "Improve code readability"Guillaume Gomez-1/+1
This reverts commit eb93d1bedeab64c6f5d661df6a309a5b8a9273ca.
2023-01-13rustdoc: remove unnecessary DOM class `h1.fqn`Michael Howell-1/+1
It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-06Correctly render sidebar for relative module pathsclubby789-21/+41
2022-12-07Improve code readabilityGuillaume Gomez-1/+1
2022-10-29Generate static file hashes onceJacob Hoffman-Andrews-6/+5
2022-10-29Make --static-root-path point to static.filesJacob Hoffman-Andrews-3/+6