about summary refs log tree commit diff
path: root/src/librustdoc/html/render.rs
AgeCommit message (Collapse)AuthorLines
2019-08-26Shorten line during rendering instead of in markdownMark Rousskov-25/+35
2019-08-26Inline recurse into only callsiteMark Rousskov-57/+40
2019-08-26Transition a few fmt::Display impls to functionsMark Rousskov-3/+3
This introduces a WithFormatter abstraction that permits one-time fmt::Display on an arbitrary closure, created via `display_fn`. This allows us to prevent allocation while still using functions instead of structs, which are a bit unwieldy to thread arguments through as they can't easily call each other (and are generally a bit opaque). The eventual goal here is likely to move us off of the formatting infrastructure entirely in favor of something more structured, but this is a good step to move us in that direction as it makes, for example, passing a context describing current state to the formatting impl much easier.
2019-08-26Store only the current depthMark Rousskov-5/+5
Previously we stored the entire current path which is a bit expensive and only ever accessed its length. This stores the length directly.
2019-08-26Remove dead tracking of external param namesMark Rousskov-26/+0
2019-08-26Move source HTML generation to own moduleMark Rousskov-173/+6
2019-08-22Rollup merge of #63782 - GuillaumeGomez:theme-switch-fix, r=kinnisonMazdak Farrokhzad-8/+8
Fix confusion in theme picker functions To reproduce the bug currently: click on the theme picker button twice (to show it then hide it). Then click anywhere else: the dropdown menu appears again. The problem was coming from a confusion of what the `hideThemeButtonState` and `showThemeButtonState` were supposed to do. I switched their codes and updated the `switchThemeButtonState` function. It now works as expected. r? @kinnison
2019-08-21Fix confusion in theme picker functionsGuillaume Gomez-8/+8
2019-08-21Replaced skipStorage with saveTheme variableGuillaume Gomez-1/+1
2019-08-11Drop RefCell from IdMap in markdown renderingMark Rousskov-5/+4
2019-08-11Remove fmt::Display impls on Markdown structsMark Rousskov-5/+5
These impls prevent ergonomic use of the config (e.g., forcing us to use RefCell) despite all usecases for these structs only using their Display impls once.
2019-08-11Remove thread-local for playground configMark Rousskov-9/+20
2019-08-11Store typed PassesMark Rousskov-10/+4
2019-08-11Remove ReentrantMutexMark Rousskov-1/+1
This drops the parking_lot dependency; the ReentrantMutex type appeared to be unused (at least, no compilation failures occurred). This is technically a possible change in behavior of its users, as lock() would wait on other threads releasing their guards, but since we didn't actually remove any threading or such in this code, it appears that we never used that behavior (the behavior change is only noticeable if the type previously was used in two threads, in a single thread ReentrantMutex is useless).
2019-08-06Rollup merge of #62837 - Kinrany:patch-1, r=GuillaumeGomezMazdak Farrokhzad-7/+15
Fix theme picker blur handler: always hide instead of switching Fixes a minor bug in UI generated by rustdoc. For example, this page: https://doc.rust-lang.org/std/ Reproduction steps: 1. Click the theme picker twice * The list of themes will be shown and then hidden 2. Click anywhere else * The list of themes will be show again, which is unexpected The bug was caused by blur event handler toggling the state of the element instead of always hiding it regardless of the current state.
2019-08-05Display methods from DerefMut in the sidebar as wellGuillaume Gomez-3/+5
2019-08-03Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centrilbors-11/+11
Change opaque type syntax from `existential type` to type alias `impl Trait` This implements a new feature gate `type_alias_impl_trait` (this is slightly different from the originally proposed feature name, but matches what has been used in discussion since), deprecating the old `existential_types` feature. The syntax for opaque types has been changed. In addition, the "existential" terminology has been replaced with "opaque", as per previous discussion and the RFC. This makes partial progress towards implementing https://github.com/rust-lang/rust/issues/63063. r? @Centril
2019-08-02Replace "existential" by "opaque"varkor-11/+11
2019-08-02librustdoc: Unconfigure tests during normal buildVadim Petrochenkov-30/+3
2019-08-01Rollup merge of #62971 - GuillaumeGomez:keyword-sidebar, r=nobodyPietro Albini-1/+2
Add keywords item into the sidebar Fixes #62939. cc @pravic screenshot of the result: ![Screenshot from 2019-07-25 14-29-48](https://user-images.githubusercontent.com/3050060/61874545-f9512080-aee8-11e9-8e8b-aa50216aec94.png) r? @QuietMisdreavus
2019-07-28Update minifier-rs versionGuillaume Gomez-4/+4
2019-07-25Add keywords item into the sidebarGuillaume Gomez-1/+2
2019-07-20Update render.rsKinrany-1/+1
2019-07-20Fix theme picker blur handler: always hide instead of switchingKinrany-7/+15
2019-07-18Replace deref with as_derefYuki Okushi-1/+1
2019-07-18fixed breaking changesBrad Gibson-4/+4
2019-07-11Remove feature gate `dropck_parametricity` completelyLzu Tao-1/+0
Therefore we also remove `#[unsafe_destructor_blind_to_params]` attribute completly.
2019-07-11Remove `MacroKind::ProcMacroStub`Vadim Petrochenkov-2/+0
It's internal to resolve and always results in `Res::Err` outside of resolve. Instead put `DefKind::Fn`s themselves into the macro namespace, it's ok. Proc macro stubs are items placed into macro namespase for functions that define proc macros. https://github.com/rust-lang/rust/pull/52383 The rustdoc test is changed because the old test didn't actually reproduce the ICE it was supposed to reproduce.
2019-07-05Rollup merge of #62123 - jeremystucki:needless_lifetimes_std, r=alexcrichtonMazdak Farrokhzad-1/+1
Remove needless lifetimes (std) Split from #62039
2019-07-01Convert more usages overChris Gregory-1/+1
2019-07-01Remove needless lifetimesJeremy Stucki-1/+1
2019-06-26remove unused derives and variantsAndy Russell-3/+0
2019-06-21Better handling of the sender channel part in rustdoc file writingGuillaume Gomez-2/+2
2019-06-21Handle fs errors through errors::Handler instead of eprintln and panicGuillaume Gomez-4/+18
2019-06-21Add DocFS layer to rustdocRobert Collins-136/+152
* Move fs::create_dir_all calls into DocFS to provide a clean extension point if async extension there is needed. * Convert callsites of create_dir_all to ensure_dir to reduce syscalls. * Convert fs::write usage to DocFS.write (which also removes a lot of try_err! usage for easier reading) * Convert File::create calls to use Vec buffers and then DocFS.write in order to consistently reduce syscalls as well, make deferring to threads cleaner and avoid leaving dangling content if writing to existing files.... * Convert OpenOptions usage similarly - I could find no discussion on the use of create_new for that one output file vs all the other files render creates, if link redirection attacks are a concern DocFS will provide a good central point to introduce systematic create_new usage. (fs::write/File::create is vulnerable to link redirection attacks). * DocFS::write defers to rayon for IO on Windows producing a modest speedup: before this patch on my development workstation: $ time cargo +mystg1 doc -p winapi:0.3.7 Documenting winapi v0.3.7 Finished dev [unoptimized + debuginfo] target(s) in 6m 11s real 6m11.734s Afterwards: $ time cargo +mystg1 doc -p winapi:0.3.7 Compiling winapi v0.3.7 Documenting winapi v0.3.7 Finished dev [unoptimized + debuginfo] target(s) in 49.53s real 0m49.643s I haven't measured how much time is in the compilation logic vs in the IO and outputting etc, but this takes it from frustating to tolerable for me, at least for now.
2019-06-19Rollup merge of #61505 - ebarnard:doc-shrink, r=GuillaumeGomezMazdak Farrokhzad-8/+13
Only show methods that appear in `impl` blocks in the Implementors sections of trait doc pages In the "Implementors" and "Implementations on Foreign Types" sections, only show methods that appear in the `impl` block for that type. This has the benefit of - Reducing the size of the Iterator page, and other large trait documentation pages. - Retaining documentation on the `impl` blocks and functions in the `impl` blocks. - Indicating which provided methods are overridden. - Making the documentation match the structure of the code being documented. - Being a small change that can be easily backed out if issues arise. A set of Rust stdlib docs build with this change are [available here](https://ebarnard.github.io/2019-06-03-rust-smaller-trait-implementers-docs/). The size of the [`Iterator` doc page](https://ebarnard.github.io/2019-06-03-rust-smaller-trait-implementers-docs/std/iter/trait.Iterator.html) is reduced from 14.4MB (latest nightly) to 724kB. Before: <img width="1411" alt="Screenshot 2019-06-03 at 23 12 17" src="https://user-images.githubusercontent.com/1059683/58837971-1722a780-8655-11e9-8d81-51e48130951d.png"> After: <img width="1428" alt="Screenshot 2019-06-03 at 16 41 27" src="https://user-images.githubusercontent.com/1059683/58814907-84ffac80-861e-11e9-8692-79be473a5299.png"> cc #55900
2019-06-11rustdoc: deny(unused_lifetimes).Eduard-Mihai Burtescu-1/+1
2019-06-03Only show methods that appear in the impl block for types in the ↵Edward Barnard-8/+13
Implementors and Implementations on Foreign Types sections of trait documentation pages.
2019-06-01Rollup merge of #61263 - GuillaumeGomez:valid-html, r=ManishearthMazdak Farrokhzad-1/+1
Don't generate div inside header (h4/h3/h...) elements Fixes #60865. According to the HTML spec, we're not supposed to put `div` elements inside heading elements (h4/h3/h...). It doesn't change the display as far as I could tell. r? @QuietMisdreavus
2019-05-29Don't generate div inside header (h4/h3/h...) elementsGuillaume Gomez-1/+1
2019-05-26Rename "Associated*" to "Assoc*"Andrew Xu-12/+12
We are going to uniform the terminology of all associated items. Methods that may or may not have `self` are called "associated functions". Because `AssociatedFn` is a bit long, we rename `Associated` to `Assoc`.
2019-05-19Auto merge of #60065 - QuietMisdreavus:async-move-doctests, r=ollie27bors-6/+12
rustdoc: set the default edition when pre-parsing a doctest Fixes https://github.com/rust-lang/rust/issues/59313 (possibly more? i think we've had issues with parsing edition-specific syntax in doctests at some point) When handling a doctest, rustdoc needs to parse it beforehand, so that it can see whether it declares a `fn main` or `extern crate my_crate` explicitly. However, while doing this, rustdoc doesn't set the "default edition" used by the parser like the regular compilation runs do. This caused a problem when parsing a doctest with an `async move` block in it, since it was expecting the `move` keyword to start a closure, not a block. This PR changes the `rustdoc::test::make_test` function to set the parser's default edition while looking for a main function and `extern crate` statement. However, to do this, `make_test` needs to know what edition to set. Since this is also used during the HTML rendering process (to make playground URLs), now the HTML renderer needs to know about the default edition. Upshot: rendering standalone markdown files can now accept a "default edition" for their doctests with the `--edition` flag! (I'm pretty sure i waffled around how to set that a long time ago when we first added the `--edition` flag... `>_>`) I'm posting this before i stop for the night so that i can write this description while it's still in my head, but before this merges i want to make sure that (1) the `rustdoc-ui/failed-doctest-output` test still works (i expect it doesn't), and (2) i add a test with the sample from the linked issue.
2019-05-19Rollup merge of #60931 - cuviper:array-iter, r=KodrAusMazdak Farrokhzad-1/+1
Use iter() for iterating arrays by slice These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-18Auto merge of #60093 - GuillaumeGomez:fix-attrs-pos, r=Manishearthbors-25/+42
Fix attrs pos Fixes #60042. Screenshot: <img width="438" alt="Screenshot 2019-05-12 at 15 02 25" src="https://user-images.githubusercontent.com/3050060/57582606-1455ec00-74c7-11e9-9d4e-5ec4da4de7dd.png"> r? @rust-lang/rustdoc
2019-05-17Use iter() for iterating arrays by sliceJosh Stone-1/+1
These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-14Add comment to explain what is the top parameterGuillaume Gomez-0/+8
2019-05-13Return a `Symbol` from `name_or_empty` functions.Nicholas Nethercote-17/+17
2019-05-13Pass a `Symbol` to `check_name`, `emit_feature_err`, and related functions.Nicholas Nethercote-5/+6
2019-05-06set the default edition when pre-parsing a doctestQuietMisdreavus-6/+12
2019-05-03use span instead of div for since versionAndy Russell-1/+1