about summary refs log tree commit diff
path: root/src/librustdoc/html/format.rs
AgeCommit message (Collapse)AuthorLines
2021-04-17rustdoc: get rid of CURRENT_DEPTHMichael Howell-40/+43
2021-04-17rustdoc: move the cx argument to the end of the listMichael Howell-13/+13
This should help make things consistent.
2021-04-17rustdoc: change 'cx to 'tcx, to match the struct itselfMichael Howell-60/+60
2021-04-17rustdoc: use more precise relative URLSMichael Howell-264/+253
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-17Auto merge of #84246 - notriddle:rustdoc-path-printing-cleanup, r=jyn514bors-42/+0
rustdoc: get rid of unused path printing code The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has a function that does the same thing without HTML support, so use that instead.
2021-04-16rustdoc: get rid of unused path printing codeMichael Howell-42/+0
The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has a function that does the same thing without HTML support, so use that instead.
2021-04-10rustdoc: clean up and test macro visibility printMichael Howell-10/+38
This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
2021-03-24Rework rustdoc const typeGuillaume Gomez-313/+404
2021-03-07Avoid temporary allocations in `render_assoc_item`Joshua Nelson-0/+4
`render_assoc_item` came up as very hot in a profile of rustdoc on `bevy`. This avoids some temporary allocations just to calculate the length of the header. This should be a strict improvement, since all string formatting was done twice before.
2021-02-06Restore linking to itself in implementors section of trait pageLeSeulArtichaut-43/+2
2021-02-05Rollup merge of #81497 - camelid:rustdoc-display_fn-remove-cell, r=jyn514Mara Bos-11/+11
rustdoc: Move `display_fn` struct inside `display_fn` This makes it clear that it's an implementation detail of `display_fn` and shouldn't be used elsewhere, and it enforces in the compiler that no one else can use it. r? ````@GuillaumeGomez````
2021-01-29rustdoc: Move `display_fn` struct inside `display_fn`Camelid-11/+11
This makes it clear that it's an implementation detail of `display_fn` and shouldn't be used elsewhere, and it enforces in the compiler that no one else can use it.
2021-01-27rustdoc: Render HRTB correctly for bare functionsCamelid-6/+15
The angle brackets were not rendered, so code like this: some_func: for<'a> fn(val: &'a i32) -> i32 would be rendered as: some_func: fn'a(val: &'a i32) -> i32 However, rendering with angle brackets is still invalid syntax: some_func: fn<'a>(val: &'a i32) -> i32 so now it renders correctly as: some_func: for<'a> fn(val: &'a i32) -> i32 ----- However, note that this code: some_trait: dyn for<'a> Trait<'a> will still render as: some_trait: dyn Trait<'a> which is not invalid syntax, but is still unclear. Unfortunately I think it's hard to fix that case because there isn't enough information in the `rustdoc::clean::Type` that this code operates on. Perhaps that case can be fixed in a later PR.
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-228/+279
2021-01-09Replace under-used ImplPolarity enum with a booleanGuillaume Gomez-1/+1
2021-01-01clippy fixes for librustdocMatthias Krüger-9/+9
fixes clippy warnings of type: match_like_matches_macro or_fun_call op_ref needless_return let_and_return single_char_add_str useless_format unnecessary_sort_by match_ref_pats redundant_field_names
2020-12-31Add FIXME for visibility of a moduleCamelid-0/+3
2020-12-30Update `find_nearest_parent_module`Camelid-3/+3
2020-12-25Prefer `pub(crate)` over no modifierCamelid-3/+3
2020-12-25Handle `pub(super)`Camelid-1/+9
2020-12-25Fix bugs; fix and add testsCamelid-27/+29
2020-12-25rustdoc: Render visibilities succinctlyCamelid-2/+11
2020-12-18Remove `DefPath` from `Visibility` and calculate it on demandJoshua Nelson-5/+6
2020-12-17Continue String to Symbol conversion in rustdocGuillaume Gomez-9/+8
2020-12-16Replace String with Symbol where possibleGuillaume Gomez-8/+5
2020-11-17Add `from_def_id_and_kind` reducing duplication in rustdocJoshua Nelson-1/+0
- Add `Item::from_hir_id_and_kind` convenience wrapper - Make name parameter mandatory `tcx.opt_item_name` doesn't handle renames, so this is necessary for any item that could be renamed, which is almost all of them. - Override visibilities to be `Inherited` for enum variants `tcx.visibility` returns the effective visibility, not the visibility that was written in the source code. `pub enum E { A, B }` always has public variants `A` and `B`, so there's no sense printing `pub` again. - Don't duplicate handling of `Visibility::Crate` Instead, represent it as just another `Restricted` path.
2020-11-17Use DefPath for clean::Visibility, not clean::PathJoshua Nelson-5/+18
Visibility needs much less information than a full path, since modules can never have generics. This allows constructing a Visibility from only a DefId. Note that this means that paths are now normalized to their DefPath. In other words, `pub(self)` or `pub(super)` now always shows `pub(in path)` instead of preserving the original text.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-14/+14
This gives warnings about dead code.
2020-10-09Simplify included import items handlingGuillaume Gomez-8/+8
2020-10-09Correctly handle "pub use" reexportsGuillaume Gomez-2/+2
2020-08-31Fix strings indentGuillaume Gomez-1/+1
2020-07-27Extract `Cache` and other types from `html` moduleJoseph Ryan-9/+11
2020-07-16Revert "Remove "important traits" feature"Manish Goregaokar-0/+12
This reverts commit 1244ced9580b942926afc06815e0691cf3f4a846.
2020-06-26Generate docs for links to private items when passed --document-privateJoshua Nelson-1/+1
- Pass around document_private a lot more - Add tests + Add tests for intra-doc links to private items + Add ignored tests for warnings in reference links
2020-02-27Remove "important traits" featureGuillaume Gomez-12/+0
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-1/+1
2020-01-26rustdoc: Fix re-exporting primitive typesOliver Middleton-5/+8
* Generate links to the primitive type docs for re-exports. * Don't ICE on cross crate primitive type re-exports. * Make primitive type re-exports show up cross crate.
2020-01-20Add `MaybeConst` variant to `{ast,hir}::TraitBoundModifier`Dylan MacKenzie-0/+1
2020-01-07Rollup merge of #67908 - ollie27:rustdoc_const_html_escape, r=GuillaumeGomezYuki Okushi-3/+14
rustdoc: HTML escape const values r? @GuillaumeGomez
2020-01-05rustdoc: HTML escape const valuesOliver Middleton-3/+14
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-2/+2
2020-01-04canonicalize FxHash{Map,Set} importsMazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-254/+285
2019-12-22Implement PrintWithSpace trait on hir::MutabilityGuillaume Gomez-11/+11
2019-12-08Sort auto trait and blanket implementations displayGuillaume Gomez-0/+11
2019-09-28rustc: rely on c_variadic == true instead of CVarArgs in HIR/Ty fn signatures.Eduard-Mihai Burtescu-4/+11
2019-09-13Remove *Space wrappers in favor of direct impls or functionsMark Rousskov-68/+43
2019-09-13Unwrap Visibility fieldsMark Rousskov-6/+2
There's not really any reason to not have the visibility default to inherited, and this saves us the trouble of checking everywhere for whether we have a visibility or not.
2019-09-13Move to print functions on types instead of impl fmt::DisplayMark Rousskov-413/+468
This will eventually allow us to easily pass in more parameters to the functions without TLS or other such hacks
2019-09-07Move to buffers throughout print_itemMark Rousskov-3/+3