about summary refs log tree commit diff
path: root/src/librustdoc/html/layout.rs
AgeCommit message (Collapse)AuthorLines
2020-10-28rustdoc: Provide a general --default-setting SETTING[=VALUE] optionIan Jackson-1/+1
We just plumb through what the user tells us. This is flagged as unstable, mostly because I don't understand the compatibility rules that rustdoc obeys for local storage data, and how error handling of invalid data works. We collect() the needed HashMap from Vec of Vecs of (key, value) pairs, so that there is a nice place to add new more-specific options. It would have been possible to use Extend::extend but doing it this way ensures that all the used inputs are (and will stay) right next to each other. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: Provide a way to set the default settings from Rust codeIan Jackson-0/+8
rustdoc has various user-configurable preferences. These are recorded in web Local Storage (where available). But we want to provide a way to configure the default default, including for when web storage is not available. getSettingValue is the function responsible for looking up these settings. Here we make it fall back some in-DOM data, which ultimately comes from RenderOptions.default_settings. Using HTML data atrtributes is fairly convenient here, dsspite the need to transform between snake and kebab case to avoid the DOM converting kebab case to camel case (!) We cache the element and dataset lookup in a global variable, to ensure that getSettingValue remains fast. The DOM representation has to be in an element which precedes the inclusion of storage.js. That means it has to be in the <head> and we should not use an empty <div> as the container (although most browsers will accept that). An empty <script> element provides a convenient and harmless container object. <meta> would be another possibility but runs a greater risk of having unwanted behaviours on weird browsers. We trust the RenderOptions not to contain unhelpful setting names, which don't fit nicely into an HTML attribute. It's awkward to quote dataset keys. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-09-23Use theme-adaptive SVG favicon from other Rust sitesJarek Samic-1/+3
2020-08-31Fix strings indentGuillaume Gomez-2/+2
2020-08-11Rollup merge of #75366 - GuillaumeGomez:help-button, r=jyn514Dylan DPC-0/+1
Add help button Part of #75197. Here is a screenshot of the result: ![Screenshot from 2020-08-10 16-53-20](https://user-images.githubusercontent.com/3050060/89796547-14112a00-db2a-11ea-9f25-57b30ab68f9b.png) r? @jyn514
2020-08-10Add help buttonGuillaume Gomez-0/+1
2020-08-07Only add a border for the rust logoGuillaume Gomez-1/+1
2020-07-12Clean up handling of style files in rustdocJarek Samic-11/+14
Disable all themes other than `light.css` to prevent rule conflicts
2020-05-07Merge aliases and search-indexGuillaume Gomez-1/+0
2019-12-22Format the worldMark Rousskov-68/+88
2019-11-20Rollup merge of #66298 - Ppjet6:disable-search-field, r=GuillaumeGomezMazdak Farrokhzad-1/+2
rustdoc: fixes #64305: disable search field instead of hidding it The result seems to be ok but I wasn't entirely sure how to get there. I tried to stay generic a bit but maybe it's not required at all. @GuillaumeGomez Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-20rustdoc: fixes #64305: disable search field instead of hidding itMaxime “pep” Buquet-1/+2
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-18Apply review commentsGuillaume Gomez-4/+6
2019-10-27reduce size of generated HTML files by moving the popup helper code to the JSGuillaume Gomez-55/+0
2019-10-26Add more information on searchGuillaume Gomez-0/+8
2019-09-13Replace SlashChecker with ensure_trailing_slashMark Rousskov-2/+2
2019-09-07layout::render takes Print instead of fmt::DisplayMark Rousskov-4/+3
2019-09-07Implement Print for FnOnce(&mut Buffer)Mark Rousskov-1/+1
This means that callers can pass in a closure like `|buf| some_function(..., &mut buf)` and pass in arbitrary arguments to that function without complicating the trait definition. We also keep the impl for str and String, since it's useful to be able to just pass in "" or format!("{}"...) results in some cases. This changes Print's definition to take self, instead of &self, because otherwise FnOnce cannot be called directly. We could instead take FnMut or even Fn, but that seems like it'd merely complicate matters -- most of the time, the FnOnce does not constrain us at all anyway. If it does, a custom Print impl for &'_ SomeStruct is not all that painful.
2019-09-07Move sidebar to Buffer-printingMark Rousskov-2/+3
2019-09-07Remove unnecessary Buffer in layout::renderMark Rousskov-6/+2
2019-09-07Move constant parameters to render to Layout structMark Rousskov-4/+8
2019-09-07Create buffers in top-level renderingMark Rousskov-5/+6
This avoids needlessly creating and threading the buffers through when we only use them once.
2019-09-07Migrate top-level rendering to BufferMark Rousskov-4/+4
2019-04-29Fix image position and displayGuillaume Gomez-4/+2
2019-04-29Wrap logo in container to prevent layout reflowJakob Ståhl-2/+4
2019-04-29Revert "Explicitly set height on rust logo <img> element in docs"Jakob Ståhl-2/+2
This reverts commit d79a01b72f4722611cb21b719e6243aad3e7ec3c.
2019-04-29Explicitly set height on rust logo <img> element in docsJakob Ståhl-2/+2
The layout of the left side menu in docs reflows when navigating between pages because of missing height on the <img> element of rust logo. Setting height='100' tells the browser to reserve that vertical space, leading to a less janky experience.
2019-04-12Apply resource-suffix to search-index and source-files scripts as wellGuillaume Gomez-2/+2
2019-02-23Transition librustdoc to 2018 editionHirokazu Hata-4/+3
2019-02-01Fix image link in the settings menuGuillaume Gomez-10/+18
2019-01-20Add default favicon for documentationGuillaume Gomez-1/+3
2019-01-20Add default rust logo for documentationGuillaume Gomez-1/+4
2018-12-29Auto merge of #57006 - GuillaumeGomez:no-crate-filter, r=QuietMisdreavusbors-8/+17
Add no-crate filter option on rustdoc @onur asked me about it so here it is! r? @QuietMisdreavus
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-24Add no-crate filter option on rustdocGuillaume Gomez-8/+17
2018-12-20split extra_scripts to handle root_path shenanigansQuietMisdreavus-4/+10
2018-12-20new --static-root-path flag for controlling static file locationsQuietMisdreavus-14/+25
2018-12-15Auto merge of #56005 - GuillaumeGomez:speedup-doc-render, r=QuietMisdreavusbors-0/+1
Greatly improve rustdoc rendering speed issues Fixes #55900. So a few improvements here: * we're switching to `DOMTokenList` API when available providing a replacement if it isn't (should only happen on safari and IE I think...) * hide doc sections by default to allow the whole HTML generation to happen in the background to avoid triggering DOM redraw all the times (which killed the performances) r? @QuietMisdreavus
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-3/+3
2018-12-06Show everything when noscript is onGuillaume Gomez-0/+1
2018-12-06Rollup merge of #56332 - GuillaumeGomez:specifi-crate-search, r=QuietMisdreavusPietro Albini-5/+13
[rustdoc] Specific crate search Reopening of #54706. Fixes #54616. <img width="1440" alt="screenshot 2018-11-29 at 01 29 11" src="https://user-images.githubusercontent.com/3050060/49191372-979adf80-f376-11e8-963e-e4feb927c1da.png"> r? @QuietMisdreavus
2018-12-03Don't generate suffix for source-file.jsGuillaume Gomez-3/+2
2018-11-29Add arrow to the crate select boxGuillaume Gomez-0/+3
2018-11-28Add crate filteringGuillaume Gomez-5/+10
2018-11-24Source sidebar improvementsGuillaume Gomez-2/+3
2018-11-24Add source file sidebarGuillaume Gomez-1/+7
2018-10-17[librustdoc] Disable spellcheck for search fieldAlexander Komarov-0/+1
2018-08-23use String::new() instead of String::from(""), "".to_string(), "".to_owned() ↵Matthias Krüger-3/+3
or "".into()
2018-07-25Add missing dynTatsuyuki Ishi-2/+2
2018-04-27fix search load page failureGuillaume Gomez-1/+1