about summary refs log tree commit diff
path: root/src/librustdoc/html/render/context.rs
AgeCommit message (Collapse)AuthorLines
2021-10-08Move template initialization into its own file.Jacob Hoffman-Andrews-12/+2
2021-10-08Add template for print_itemJacob Hoffman-Andrews-2/+6
Add print_item.html and the code in print_item.rs to use it.
2021-09-16Auto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomezbors-7/+7
rustdoc: reduce number of copies when using parallel IO This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason. Helps with https://github.com/rust-lang/rust/issues/82741. Follow-up to https://github.com/rust-lang/rust/pull/60971.
2021-09-05Change more x64 size checks to not apply to x32.Harald van Dijk-1/+1
Commit 95e096d6 changed a bunch of size checks already, but more have been added, so this fixes the new ones the same way: the various size checks that are conditional on target_arch = "x86_64" were not intended to apply to x86_64-unknown-linux-gnux32, so add target_pointer_width = "64" to the conditions.
2021-08-26Remove unnecessary copies when using parallel IOJoshua Nelson-7/+7
Previously, rustdoc was making lots of copies of temporary owned values. Now, it uses the owned value wherever possible.
2021-08-22Move Cache from Context to SharedContextJoshua Nelson-19/+10
2021-08-05Remove LightSpan and use Span directlyGuillaume Gomez-3/+3
2021-08-05Wrap the span_map tuple index into a type called "LightSpan"Guillaume Gomez-3/+3
2021-08-05Add an option for the source code link generationGuillaume Gomez-2/+8
2021-08-05Add links on source types to go to definitionGuillaume Gomez-23/+41
2021-07-17Rustdoc accessibility: make the sidebar headers actual headersMichael Howell-2/+2
Part of #87059 Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html
2021-07-05rustdoc: Rename `expect_real` to `expect_def_id`, remove `Item::is_fake`Justus K-1/+1
2021-06-20Use Tera templates for rustdoc.Jacob Hoffman-Andrews-0/+14
Replaces a format!() call in layout::render with a template expansion. Introduces a `templates` field in SharedContext so parts of rustdoc can share pre-rendered templates. This currently builds in a copy of the single template available, like with static files. However, future work can make this live-loadable with a perma-unstable flag, to make rustdoc developers' work easier.
2021-06-10manually crafted revert of PR #80653, to address issue #82465.Felix S. Klock II-7/+2
(update: placated tidy) (update: rebased post PR #84707 ) merge me
2021-05-31Only list crates on the crate pageGuillaume Gomez-1/+8
2021-05-12Rollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jshaGuillaume Gomez-2/+2
Update documentation for SharedContext::maybe_collapsed_doc_value Fixes #85120. The `doc-collapse` was removed, however, the main crate is always "collapsed", meaning that this function is still needed. I updated the documentation instead to avoid misleading readers. r? `@jsha`
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-2/+2
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-11Only show type layout info if `--show-type-layout` is passedCamelid-0/+4
2021-05-10Use an SVG image for clipboard instead of unicode characterGuillaume Gomez-1/+1
2021-05-10Update documentation for SharedContext::maybe_collapsed_doc_valueGuillaume Gomez-2/+2
2021-05-07Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkovDylan DPC-1/+1
Unify rustc and rustdoc parsing of `cfg()` This extracts a new `parse_cfg` function that's used between both. - Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)] #[doc(cfg(y))]`. Previously it would be completely ignored. - Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)] #[doc(cfg(x))]`. Previously, the cfg would be ignored. - Pass the cfg predicate through to rustc_expand to be validated Technically this is a breaking change, but doc_cfg is still nightly so I don't think it matters. Fixes https://github.com/rust-lang/rust/issues/84437. r? `````````@petrochenkov`````````
2021-05-05Use local and remapped paths where appropriateAndy Wang-11/+4
2021-05-05Make local_path in RealFileName::Remapped Option to be removed in exported ↵Andy Wang-5/+12
metadata
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-2/+3
2021-05-03Unify rustc and rustdoc parsing of `cfg()`Joshua Nelson-1/+1
This extracts a new `parse_cfg` function that's used between both. - Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)] #[doc(cfg(y))]`. Previously it would be completely ignored. - Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)] #[doc(cfg(x))]`. Previously, the cfg would be ignored. - Pass the cfg predicate through to rustc_expand to be validated Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-04-29only store locations in extern_locationsTimothée Delabrouille-5/+9
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.