summary refs log tree commit diff
path: root/src/librustdoc/html/render/context.rs
AgeCommit message (Collapse)AuthorLines
2023-02-15Use more let chainGuillaume Gomez-8/+6
2023-02-11rustdoc: account for intra-doc links in `<meta name="description">`Michael Howell-1/+4
2023-01-31rustdoc: remove inconsistently-present sidebar tooltipsMichael Howell-6/+3
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-30rustdoc: remove meta keywords from HTMLMichael Howell-8/+1
Discussed in <https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.60.3Cmeta.20name.3D.22keywords.22.3E.60>
2023-01-22rustdoc: Use `DefId(Map,Set)` instead of `FxHash(Map,Set)`Vadim Petrochenkov-4/+4
Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept.
2023-01-14Rollup merge of #106855 - klensy:rd-s, r=notriddleMatthias Krüger-3/+2
rustdoc: few small cleanups
2023-01-13rustdoc: remove unnecessary DOM class `h1.fqn`Michael Howell-2/+2
It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-13Playground.crate_name String -> Symbolklensy-3/+2
2023-01-06Correctly render sidebar for relative module pathsclubby789-4/+18
2022-12-12rustdoc: remove `type="text/css" from stylesheet linksMichael Howell-1/+1
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web." Like 07a243b2a46384235d7e2c08688978b7cf018973, but a few places that were missed the first time.
2022-11-07rustdoc: use javascript to layout notable traits popupsMichael Howell-1/+6
Fixes #102576
2022-10-29Make --static-root-path point to static.filesJacob Hoffman-Andrews-1/+1
2022-10-29rustdoc: add hash to filename of toolchain filesJacob Hoffman-Andrews-19/+7
All static files used by rustdoc are now stored in static.files/ and include a hash of their contents. They no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration.
2022-10-19Avoid cloning `RenderOptions`.Nicholas Nethercote-2/+1
By moving `RenderOptions` out of `Option`, because the two structs' uses are almost entirely separate. The only complication is that `unstable_features` is needed in both structs, but it's a tiny `Copy` type so its duplication seems fine.
2022-10-15rustdoc: make the help button a link to a pageMichael Howell-0/+34
This allows you to open the help section in a new browser tab, which is a pretty reasonable thing to want for a documentation page.
2022-10-05rustdoc: remove unused CSS class `in-band`Michael Howell-3/+1
Since a7c25b29575c17434406b69773f8c2961af343b3 removed `in-band` from code headers, the only remaining uses of the `in-band` class are: https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/write_shared.rs#L520-L521 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/templates/print_item.html#L2-L3 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/context.rs#L637-L638 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L368-L369 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L401-L402 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/static/js/main.js#L525 Since all of these uses are nested below `h1.fqn`, we can get rid of it, and the support code that was used for when `in-band` was part of item rendering.
2022-09-20Generate sidebar elements for the "All items" pageGuillaume Gomez-8/+16
2022-09-15rustdoc: use more precise URLs for jump-to-definition linksMichael Howell-0/+30
As an example, this cuts down <https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/ty/mod.rs.html> by about 11%. $ du -h new_mod.rs.html old_mod.rs.html 296K new_mod.rs.html 332K old_mod.rs.html
2022-08-24Auto merge of #96869 - sunfishcode:main, r=joshtriplettbors-1/+1
Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8. Add a `is_known_utf8` flag to `Wtf8Buf`, which tracks whether the string is known to contain UTF-8. This is efficiently computed in many common situations, such as when a `Wtf8Buf` is constructed from a `String` or `&str`, or with `Wtf8Buf::from_wide` which is already doing UTF-16 decoding and already checking for surrogates. This makes `OsString::into_string` O(1) rather than O(N) on Windows in common cases. And, it eliminates the need to scan through the string for surrogates in `Args::next` and `Vars::next`, because the strings are already being translated with `Wtf8Buf::from_wide`. Many things on Windows construct `OsString`s with `Wtf8Buf::from_wide`, such as `DirEntry::file_name` and `fs::read_link`, so with this patch, users of those functions can subsequently call `.into_string()` without paying for an extra scan through the string for surrogates. r? `@ghost`
2022-08-13make clean::Item::span return option instead of dummy spanMichael Goulet-4/+1
2022-06-29Replace `sort_modules_alphabetically` boolean with enumNoah Lev-7/+10
This fixes the long-standing FIXME there and makes the code easier to understand. The reference to modules in both the old and new names seems potentially wrong since I believe it applies to all items.
2022-06-23Don't test the rustdoc rendering context size on Windows.Dan Gohman-1/+1
This assert is just making sure the size of `Context` doens't grow unexpectedly, and it's already not being checked on every platform. `PathBuf` now has a different size on Windows, so adjust this to avoid checking the size on Windows.
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-5/+1
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-05-28Improve settings page display with disabled javascriptGuillaume Gomez-0/+5
2022-05-27Pass Context as a &mut to allow to remove RefCell fieldsGuillaume Gomez-38/+43
2022-05-24fix simple clippy lintsklensy-4/+4
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-19/+19
2022-05-18Move some DOM generation into the HTML settings file directlyGuillaume Gomez-3/+13
2022-05-11Add missing CSS file for settings pageGuillaume Gomez-3/+5
2022-04-30Move settings into full JSGuillaume Gomez-13/+10
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-1/+1
2022-03-27Add scrape examples help pageWill Crichton-2/+17
2022-03-04librustdoc: adopt let else in more placesest31-4/+2
2022-02-22Prevent generation of infinite redirectionsGuillaume Gomez-26/+34
2022-02-14Fix macro reexports duplicates in the sidebarGuillaume Gomez-6/+11
2022-01-18Simplify and unify rustdoc sidebar stylesJacob Hoffman-Andrews-10/+2
This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise. I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler. Because the heading font sizes are bigger, increase the sidebar width slightly. As a very minor change, removed version from the "All types" page. It's now only on the crate page.
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-10/+10
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2022-01-13Auto merge of #92526 - djc:rustdoc-askama, r=jshabors-11/+1
Migrate rustdoc from Tera to Askama See #84419. Should probably get a benchmarking run to verify if it has the intended effect on rustdoc performance. cc `@jsha` `@jyn514.`
2022-01-12Rollup merge of #92742 - GuillaumeGomez:missing-suffix-sidebar-items, ↵Matthias Krüger-1/+1
r=notriddle Add missing suffix for sidebar-items script path Fixes https://github.com/rust-lang/docs.rs/issues/1590. r? ```@syphar```
2022-01-10Add missing suffix for sidebar-items script pathGuillaume Gomez-1/+1
2022-01-10Remove configuration which became unused in ↵Dirkjan Ochtman-2/+0
8abb4bb698c9d74507adb9cd7b54a032f3c1b595
2022-01-10Migrate rustdoc from Tera to AskamaDirkjan Ochtman-9/+1
See #84419.
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-1/+1
Change from syntaxy-looking [src] to the plain word "source".
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-2/+2
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-1/+1
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-23Rollup merge of #92146 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-6/+10
Don't emit shared files when scraping examples from dependencies in Rustdoc This PR fixes #91605. The issue is that `Context::init` gets called when scraping dependencies. By default, just calling `init` calls into `write_shared` and `build_index` which register the scraped crate into a list that later gets used for the Rustdoc sidebar. The fix is to ensure that `write_shared` is not called when scraping. r? `@jyn514`
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-9/+0
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-18Remove `collapsed` fieldJoshua Nelson-9/+0
`render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-5/+5
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-3/+3
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!