summary refs log tree commit diff
path: root/src/librustdoc/html/render/context.rs
AgeCommit message (Collapse)AuthorLines
2021-05-04manually crafted revert of PR #80653, to address issue #82465.Felix S. Klock II-7/+2
(update: placated tidy)
2021-04-27Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of ↵Timothée Delabrouille-1/+1
the fields in Attributes, as functions in AttributesExt. refacto use from_def_id_and_attrs_and_parts instead of an old trick most of josha suggestions + check if def_id is not fake before using it in a query Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of the Attributes fields as functions in AttributesExt.
2021-04-24Get rid of `item.span`Joshua Nelson-5/+5
- Remove `span` field, adding `Item::span()` instead - Special-case `Impl` and `Module` items - Use dummy spans for primitive items
2021-04-24Do the hard part firstJoshua Nelson-5/+5
The only bit failing was the module, so change that before removing the `span` field.
2021-04-22Remove unnecessary item_name parameter to `mod_item_in`Joshua Nelson-3/+4
2021-04-22Remove unnecessary `item_name` parameter to `mod_item_out`Joshua Nelson-1/+1
2021-04-22Remove unnecessary `edition` field on SharedContextJoshua Nelson-3/+4
2021-04-22Remove unnecessary `edition` parameter to rendererJoshua Nelson-2/+1
2021-04-22Remove unnecessary `diag` parameter to `after_krate`Joshua Nelson-2/+3
2021-04-22Remove unnecessary `crate_name` parameter to `after_krate`Joshua Nelson-6/+3
It's always `tcx.crate_name(LOCAL_CRATE)`, it doesn't need to be passed in separately.
2021-04-20fix is_module checkSmitty-4/+4
2021-04-20Rename pushname to is_moduleSmitty-3/+3
2021-04-20Write Rustdoc titles like "x in crate::mod - Rust"Smitty-9/+8
This makes Rustdoc titles for items read like "x in cratename::blah::foo - Rust". Title for modules and other non-items are unchanged, and still read like "doccratenameconst::blah::foo - Rust". This makes managing several open Rustdoc tabs easier. Closes #84371.
2021-04-17rustdoc: get rid of CURRENT_DEPTHMichael Howell-9/+1
2021-04-17rustdoc: use more precise relative URLSMichael Howell-2/+6
Instead of using a depth counter and adding "../" to get to the top, this commit makes rustdoc actually compare the path of what it's linking from to the path that it's linking to. This makes the resulting HTML shorter. Here's a comparison of one of the largest (non-source) files in the Rust standard library docs (about 4% improvement before gzipping). $ wc -c struct.Wrapping.old.html struct.Wrapping.new.html 2387389 struct.Wrapping.old.html 2298538 struct.Wrapping.new.html Most if it can be efficiently gzipped away. $ wc -c struct.Wrapping.old.html.gz struct.Wrapping.new.html.gz 70679 struct.Wrapping.old.html.gz 70050 struct.Wrapping.new.html.gz But it also makes a difference in the final DOM size, reducing it from 91MiB to 82MiB.
2021-04-05Move `SharedContext` to `context.rs`Camelid-7/+72
It is tightly connected to `Context` and is primarily used as a field in `Context`. Thus, it should be next to `Context`.
2021-04-03Remove unneeded INITIAL_IDS constGuillaume Gomez-5/+2
2021-04-02Rollup merge of #83478 - jyn514:fine-grained-files, r=Mark-SimulacrumDylan DPC-13/+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-03-25Add unstable option to only emit shared/crate-specific filesJoshua Nelson-1/+4
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-25Add SharedResource abstraction and use it in write_sharedJoshua Nelson-12/+1
This cleans up the code quite a bit, and also makes the next commit much easier.
2021-03-24Don't call `item` on modules for json rendererNixon Enraght-Moony-0/+2
Closes #80664
2021-03-24Rollup merge of #83415 - camelid:remove-crate-module-option, r=jyn514Dylan DPC-28/+25
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-23Remove unnecessary `Option` wrapping around `Crate.module`Camelid-28/+25
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-21Rename `clean::Item.source` to `span`Camelid-5/+5
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-05Undo addition of boxesCamelid-7/+7
I don't think the boxing helped performance, in fact I think it potentially made it worse. The data was still being copied, but now it was through a pointer. Thinking about it more, I think boxing might only help when you're passing a big object around by value all the time, rather than the slowdown being that you're cloning it.
2021-03-05Don't unnecessarily clone some fields in `Context`Camelid-6/+15
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-05Box some fields to reduce `Context` sizeCamelid-5/+5
Reduced from 152 bytes to 88 bytes.
2021-03-05Don't share `id_map` and `deref_id_map`Camelid-8/+13
All the tests passed, so it doesn't seem they need to be shared. Plus they should be item/page-specific. I'm not sure why they were shared before. I think the reason `id_map` worked as a shared value before is that it is cleared before rendering each item (in `render_item`). And then I'm guessing `deref_id_map` worked because it's a hashmap keyed by `DefId`, so there was no overlap (though I'm guessing we could have had issues in the future). Note that `id_map` currently still has to be cleared because otherwise child items would inherit the `id_map` of their parent. I'm hoping to figure out a way to stop cloning `Context`, but until then we have to reset `id_map`.
2021-03-05rustdoc: Add static size assertion for `Context`Camelid-0/+4
It's cloned a lot, so we don't want it to grow in size unexpectedly. Only run the assert on x86-64 since the size is architecture-dependent.
2021-03-05rustdoc: Make a bunch of fields privateCamelid-5/+10
Also create issue for removing shared mutable state.
2021-03-05rustdoc: Replace `Arc` around `SharedContext` with `Rc`Camelid-6/+5
It doesn't look like it's shared across threads, so it doesn't need to be thread-safe. Of course, since we're using Rust, we'll get an error if we try to share it across threads, so this should be safe :)
2021-03-05rustdoc: Move most shared fields to `SharedContext`Camelid-30/+26
...and remove `Rc`s for the moved fields. The only shared one that I didn't move was `cache`; see the doc-comment I added to `cache` for details.
2021-03-04Moved `write_shared` to its own fileNicholas-Baron-0/+1
2021-03-04Moved the `make_item_keywords` function to `context.rs` as it is only used thereNicholas-Baron-2/+6
2021-03-04Moved `print_item` and helpers to a separate fileNicholas-Baron-2/+3
2021-03-04Moved Context and its impls to a separate fileNicholas-Baron-0/+611