about summary refs log tree commit diff
path: root/src/librustdoc/formats/renderer.rs
AgeCommit message (Collapse)AuthorLines
2025-08-23Do macro expansion at AST level rather than HIRGuillaume Gomez-11/+7
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-2/+2
2025-06-19rustdoc: Remove `FormatRenderer::cache`Alona Enraght-Moony-2/+0
We only called it it one place, which isn't generic and can be replaced with a field access.
2025-06-11Avoid more clones in rustdoc JSON output.Nicholas Nethercote-7/+7
By making `JsonRenderer::item` take `&clean::Item` instead of a `clean::Item`. This required also changing `FromClean` and `IntoJson` methods to take references, which required a lot of follow-on sigil wrangling that is mostly tedious.
2025-06-10Simplify `JsonRenderer`.Nicholas Nethercote-1/+1
- It doesn't need to be cloneable. - Some of the `Rc`s and `RefCell`s aren't doing anything. - `after_krate` can consume `self`.
2024-12-02rustdoc: Rename set_back_info to restore_module_data.Alona Enraght-Moony-12/+13
2024-12-01Rename `FormatRenderer::InfoType` into `ModuleData` and rename ↵Guillaume Gomez-6/+6
`FormatRenderer::make_child_renderer` into `save_module_data`
2024-12-01Add documentation for new `FormatRenderer` trait itemsGuillaume Gomez-2/+24
2024-12-01Stop cloning `Context` so muchGuillaume Gomez-32/+40
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-1/+1
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2023-11-18Remove unneeded `unknown` variable and `Symbol` creation when iterating over ↵Guillaume Gomez-4/+4
items in rustdoc rendering
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+5
2022-10-06Remove `-Ztime` option.Nicholas Nethercote-2/+2
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used `-Ztime-passes` for years but only recently learned about `-Ztime`. What's the difference? Let's look at the `-Zhelp` output: ``` -Z time=val -- measure time of rustc processes (default: no) -Z time-passes=val -- measure time of each rustc pass (default: no) ``` The `-Ztime-passes` description is clear, but the `-Ztime` one is less so. Sounds like it measures the time for the entire process? No. The real difference is that `-Ztime-passes` prints out info about passes, and `-Ztime` does the same, but only for a subset of those passes. More specifically, there is a distinction in the profiling code between a "verbose generic activity" and an "extra verbose generic activity". `-Ztime-passes` prints both kinds, while `-Ztime` only prints the first one. (It took me a close reading of the source code to determine this difference.) In practice this distinction has low value. Perhaps in the past the "extra verbose" output was more voluminous, but now that we only print stats for a pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also, a lot of the "extra verbose" cases are for individual lint passes, and you need to also use `-Zno-interleave-lints` to see those anyway. Therefore, this commit removes `-Ztime` and the associated machinery. One thing to note is that the existing "extra verbose" activities all have an extra string argument, so the commit adds the ability to accept an extra argument to the "verbose" activities.
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-2/+2
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-04librustdoc: adopt let else in more placesest31-4/+2
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-04-22Remove unnecessary item_name parameter to `mod_item_in`Joshua Nelson-7/+4
2021-04-22Remove unnecessary `item_name` parameter to `mod_item_out`Joshua Nelson-2/+4
2021-04-22Remove unnecessary `edition` parameter to rendererJoshua Nelson-4/+2
2021-04-22Remove unnecessary `diag` parameter to `after_krate`Joshua Nelson-5/+2
2021-04-22Remove unnecessary `crate_name` parameter to `after_krate`Joshua Nelson-7/+2
It's always `tcx.crate_name(LOCAL_CRATE)`, it doesn't need to be passed in separately.
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-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-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-1/+3
transition over hir::ItemKind simpler
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-14/+3
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-05Remove Function all_types and ret_types fieldsGuillaume Gomez-0/+1
2021-01-27Update to new rustdoc APIsGuillaume Gomez-5/+2
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-23/+15
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.
2020-12-23Box ItemKind to reduce the size of `Item`Joshua Nelson-1/+1
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-2/+1
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-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-2/+2
This gives warnings about dead code.
2020-11-14Rename ItemEnum -> ItemKind, inner -> kindJoshua Nelson-1/+1
2020-07-27More requested changesJoseph Ryan-68/+58
2020-07-27Make requested changesJoseph Ryan-13/+15
2020-07-27Pull out more types from htmlJoseph Ryan-1/+3
2020-07-27Extract `Cache` and other types from `html` moduleJoseph Ryan-0/+112