about summary refs log tree commit diff
path: root/src/librustdoc/formats
AgeCommit message (Collapse)AuthorLines
2021-04-06Store links in Cache instead of on items directlyJoshua Nelson-0/+5
Items are first built after rustdoc creates the TyCtxt. To allow resolving the links before the TyCtxt is built, the links can't be stored on `clean::Item` directly.
2021-04-06Rollup merge of #83835 - notriddle:sort-index, r=ollie27Yuki Okushi-12/+1
rustdoc: sort search index items for compression This should not affect the appearance of the docs pages themselves. This makes the pre-compressed search index smaller, thanks to the empty-string path duplication format, and also the gzipped version, by giving the algorithm more structure to work with. rust$ wc -c search-index-old.js search-index-new.js 2628334 search-index-old.js 2586181 search-index-new.js 5214515 total rust$ gzip search-index-* rust$ wc -c search-index-old.js.gz search-index-new.js.gz 239486 search-index-old.js.gz 237386 search-index-new.js.gz 476872 total
2021-04-04Get rid of unneeded `aliases` fieldMichael Howell-4/+0
2021-04-03rustdoc: sort search index items for compressionMichael Howell-8/+1
This should not affect the appearance of the docs pages themselves. This makes the pre-compressed search index smaller, thanks to the empty-string path duplication format, and also the gzipped version, by giving the algorithm more structure to work with. rust$ wc -c search-index-old.js search-index-new.js 2628334 search-index-old.js 2586181 search-index-new.js 5214515 total rust$ gzip search-index-* rust$ wc -c search-index-old.js.gz search-index-new.js.gz 239486 search-index-old.js.gz 237386 search-index-new.js.gz 476872 total
2021-04-04Rollup merge of #83756 - camelid:internal-rename-doc-spotlight, r=GuillaumeGomezYuki Okushi-2/+2
rustdoc: Rename internal uses of `spotlight` I didn't make these renames in #80965 because I didn't want the PR to conflict with #80914.
2021-04-02rustdoc: Rename internal uses of `spotlight`Camelid-2/+2
I didn't make these renames in #80965 because I didn't want the PR to conflict with #80914.
2021-04-02Rollup merge of #83478 - jyn514:fine-grained-files, r=Mark-SimulacrumDylan DPC-0/+5
rustdoc: Add unstable option to only emit shared/crate-specific files The intended use case is for docs.rs, which can now copy exactly the files it cares about, rather than having to guess based on whether they have a resource suffix or not. In particular, some files have a resource suffix but cannot be shared between crates: https://github.com/rust-lang/docs.rs/pull/1312#issuecomment-798783688 The end goal is to fix rust-lang/docs.rs#1327 by reverting rust-lang/docs.rs#1324. This obsoletes `--print=unversioned-files`, which I plan to remove as soon as docs.rs stops using it. I recommend reviewing this one commit at a time. r? ``@GuillaumeGomez`` cc ``@Nemo157`` ``@pietroalbini``
2021-04-02Auto merge of #80965 - camelid:rename-doc-spotlight, r=jyn514bors-1/+1
Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` Fixes #80936. "spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation r? `@Manishearth`
2021-03-25Add unstable option to only emit shared/crate-specific filesJoshua Nelson-0/+5
The intended use case is for docs.rs, which can now copy exactly the files it cares about, rather than having to guess based on whether they have a resource suffix or not. In particular, some files have a resource suffix but cannot be shared between crates: https://github.com/rust-lang/docs.rs/pull/1312#issuecomment-798783688 The end goal is to fix https://github.com/rust-lang/docs.rs/issues/1327 by reverting https://github.com/rust-lang/docs.rs/pull/1324. This obsoletes `--print=unversioned-files`, which I plan to remove as soon as docs.rs stops using it.
2021-03-24Don't call `item` on modules for json rendererNixon Enraght-Moony-1/+6
Closes #80664
2021-03-23Remove unnecessary `Option` wrapping around `Crate.module`Camelid-13/+7
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-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-15Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`Camelid-1/+1
"spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation
2021-03-09Remove `masked_crates` from `clean::Crate`Camelid-2/+5
Previously, `masked_crates` existed both on `Cache` and on `clean::Crate`. During cache population, the `clean::Crate` version was `take`n and moved to `Cache`. This change removes the version on `clean::Crate` and instead directly mutates `Cache.masked_crates` to initialize it. This has the advantage of avoiding duplication and avoiding unnecessary allocation, as well as making the flow of information through rustdoc less confusing. The one downside I see is that `clean::utils::krate()` now uses the side effect of mutating `DocContext.cache` instead of returning the data directly, but it already mutated the `Cache` for other things (e.g., `deref_trait_did`) so it's not really new behavior. Also, `clean::utils::krate()` is only called once (and is meant to only be called once since it performs expensive and potentially destructive operations) so the mutation shouldn't be an issue.
2021-03-09Auto merge of #82356 - camelid:render-cleanup, r=GuillaumeGomezbors-3/+6
rustdoc: Cleanup `html::render::Context` - Move most shared fields to `SharedContext` (except for `cache`, which isn't mutated anyway) - Replace a use of `Arc` with `Rc` - Make a bunch of fields private - Add static size assertion for `Context` - Don't share `id_map` and `deref_id_map`
2021-03-05Don't unnecessarily clone some fields in `Context`Camelid-3/+6
There was no need to clone `id_map` because it was reset before each item was rendered. `deref_id_map` was not reset, but it was keyed by `DefId` and thus was unlikely to have collisions (at least for now). Now we just clone the fields that need to be cloned, and instead create fresh versions of the others.
2021-03-05Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make ↵Guillaume Gomez-2/+4
transition over hir::ItemKind simpler
2021-03-01Remove `krate.version`; fix `crate_version` in JSONJoshua Nelson-1/+0
Previously, `JsonRenderer::after_krate` called `krate.version.clone()`. The problem was it did that after the version was already moved into the cache, so it would always be None. The fix was to get the version from the cache instead.
2021-03-01Remove unused `RenderInfo` structJoshua Nelson-27/+3
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-41/+31
The same information is available everywhere; the only reason the dummy cache was needed is because it waas previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it means `renderinfo` is used much much less. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RefCell around `inlined` - Add intra-doc links
2021-02-23* Fix some typoGuillaume Gomez-5/+1
* Improve documentation * Add a test to ensure that spotlighted traits from dependencies are taken into account as expected
2021-02-23Put clean::Trait extra information into a new struct to make it more coherentGuillaume Gomez-5/+7
2021-02-23Remove is_spotlight field from `Trait`Guillaume Gomez-2/+8
2021-02-05Remove Function all_types and ret_types fieldsGuillaume Gomez-46/+60
2021-02-02Auto merge of #81557 - GuillaumeGomez:primitive-search, r=ollie27bors-0/+1
Fix primitive search in parameters and returned values Part of #60485. Fixes #74780. Replacing #74879. cc `@camelid` `@jyn514` `@CraftSpider` r? `@ollie27`
2021-02-01Put back primitives in searchGuillaume Gomez-0/+1
2021-01-30rustdoc tweakingbors-1/+1
* Reuse memory * simplify `next_def_id`, avoid multiple hashing and unnecessary lookups * remove `all_fake_def_ids`, use the global map instead (probably not a good step toward parallelization, though...) * convert `add_deref_target` to iterative implementation * use `ArrayVec` where we know the max number of elements * minor touchups here and there * avoid building temporary vectors that get appended to other vectors At most places I may or may not be doing the compiler's job is this PR.
2021-01-27Update to new rustdoc APIsGuillaume Gomez-5/+2
2021-01-27Remove cache usage wherever possibleGuillaume Gomez-71/+54
2021-01-27Use empty Cache for methods requiring it when filling Cache itselfGuillaume Gomez-48/+70
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-40/+25
2021-01-23Rollup merge of #81275 - jyn514:time-render, r=wesleywiserJonas Schievink-13/+23
Fix <unknown> queries and add more timing info to render_html Closes https://github.com/rust-lang/rust/issues/81251. ## Fix `<unknown>` queries This happened because `alloc_query_strings` was never called. ## Add more timing info to render_html This still has some issues I'm not sure how to work out: - `create_renderer` and `renderer_after_krate` aren't shown by default. I want something like `verbose_generic_activity_with_arg`, but it doesn't exist. I'm also not sure how to show activities that aren't on by default - I tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up. r? `@wesleywiser`
2021-01-23Add more timing info to render_htmlJoshua Nelson-13/+23
- Show `create_renderer` and `renderer_after_crate` by default - Don't rewrite `extra_verbose_generic_activity`
2021-01-21Fix rustc::internal lints on rustdocJoshua Nelson-3/+3
2021-01-19Remove unnecessary `after_run` functionJoshua Nelson-6/+9
It's called at the same time and in the same place as `after_krate`, so they can be combined.
2021-01-02Improve code for DocFragment reworkGuillaume Gomez-4/+3
2021-01-02End of rework of Attributes structGuillaume Gomez-3/+4
2020-12-23Box ItemKind to reduce the size of `Item`Joshua Nelson-32/+27
This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280 ```
2020-12-17Make it compileJoshua Nelson-4/+4
2020-12-17[tmp] Pass `TyCtxt` through to the render backendJoshua Nelson-5/+4
First actually useful step in https://github.com/rust-lang/rust/issues/76382 This doesn't yet compile because there's no way to get a `Lrc<Session>` from a TyCtxt, only a `&Session`.
2020-12-15Use `Symbol`s for crate namesJoshua Nelson-7/+7
2020-12-14Switch to Symbol for item.nameJoshua Nelson-1/+2
This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much.
2020-12-12Pass Session into rendererJoshua Nelson-1/+5
2020-12-03Render Markdown in search resultsCamelid-3/+5
Previously Markdown documentation was not rendered to HTML for search results, which led to the output not being very readable, particularly for inline code. This PR fixes that by rendering Markdown to HTML with the help of pulldown-cmark (the library rustdoc uses to parse Markdown for the main text of documentation). However, the text for the title attribute (the text shown when you hover over an element) still uses the plain-text rendering since it is displayed in browsers as plain-text. Only these styles will be rendered; everything else is stripped away: * *italics* * **bold** * `inline code`
2020-11-26Use `from_def_id_and_parts` for primitives and keywordsJoshua Nelson-2/+2
- Take `String` instead of `Symbol` - this avoids having to intern then immediately stringify the existing string. - Remove unused `get_stability` and `get_deprecation` - Remove unused `attrs` field from `primitives`
2020-11-22Make `fold_item_recur` non-nullableJoshua Nelson-40/+37
This gets rid of a bunch of `unwrap()`s and makes it a little more clear what's going on. Originally I wanted to make `fold_item` non-nullable too, which would have been a lot nicer to work with, but unfortunately `stripper` does actually return `None` in some places. I might make a follow-up moving stripper to be special and not a pass so that passes can be non-nullable.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-33/+33
This gives warnings about dead code.
2020-11-14Rename ItemEnum -> ItemKind, inner -> kindJoshua Nelson-14/+14
2020-08-30rustdoc: do not use plain summary for trait implsAndy Russell-2/+2
Fixes #38386. Fixes #48332. Fixes #49430. Fixes #62741. Fixes #73474.
2020-07-27More requested changesJoseph Ryan-81/+61