about summary refs log tree commit diff
path: root/src/librustdoc/lib.rs
AgeCommit message (Collapse)AuthorLines
2021-04-17rustdoc: use more precise relative URLSMichael Howell-1/+7
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-07Reuse logic for determining the channel in the rest of rustdocJoshua Nelson-1/+6
This doesn't update main.js because it's included as a fixed string.
2021-04-06Add listing of lints (eg via -W help) to rustdocAlan Egerton-1/+7
2021-04-04use jemallocator in rustc/rustdocGus Wynn-0/+51
2021-04-03Auto merge of #83738 - jyn514:only-load-some-crates, r=petrochenkovbors-2/+2
rustdoc: Don't load all extern crates unconditionally Instead, only load the crates that are linked to with intra-doc links. This doesn't help very much with any of rustdoc's fundamental issues with freezing the resolver, but it at least fixes a stable-to-stable regression, and makes the crate loading model somewhat more consistent with rustc's. I tested and it unfortunately does not help at all with https://github.com/rust-lang/rust/pull/82496. Closes https://github.com/rust-lang/rust/issues/68427. Let me know if you want me to open a separate issue for not freezing the resolver. r? `@petrochenkov` cc `@eddyb` `@ollie27`
2021-04-02Don't load all extern crates unconditionallyJoshua Nelson-2/+2
Instead, only load the crates that are linked to with intra-doc links. This doesn't help very much with any of rustdoc's fundamental issues with freezing the resolver, but it at least fixes a stable-to-stable regression, and makes the crate loading model somewhat more consistent with rustc's.
2021-03-31Rename CrateSpecific -> InvocationSpecificJoshua Nelson-1/+1
2021-03-25Add unstable option to only emit shared/crate-specific filesJoshua Nelson-0/+8
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-19librustdoc: or_patterns are stablemark-1/+1
2021-03-05Add an unstable option to print all unversioned filesJoshua Nelson-0/+3
This allows sharing those files between different doc invocations without having to know their names ahead of time.
2021-03-05Store `UNVERSIONED_FILES` in a data structureJoshua Nelson-0/+18
This allows querying it programatically.
2021-03-04Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomezYuki Okushi-0/+2
Make rustdoc lints a tool lint instead of built-in - Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` (and similar for other rustdoc lints; I don't expect any others to be used frequently, though). - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests - Move lint machinery into a separate file - Add `declare_rustdoc_lint!` macro Unblocks https://github.com/rust-lang/rust/pull/80300, https://github.com/rust-lang/rust/pull/79816, https://github.com/rust-lang/rust/pull/80965. Makes the strangeness in https://github.com/rust-lang/rust/pull/77364 more apparent to the end user (note that `missing_docs` is *not* moved to rustdoc in this PR). Closes https://github.com/rust-lang/rust/issues/78786. ## Current status This is blocked on #82620 (see https://github.com/rust-lang/rust/pull/80527#issuecomment-787401519)
2021-03-03Rollup merge of #81223 - GuillaumeGomez:generate-redirect-map, r=jyn514Yuki Okushi-0/+7
[rustdoc] Generate redirect map file Fixes #81134. So with this code: ```rust #![crate_name = "foo"] pub use private::Quz; pub use hidden::Bar; mod private { pub struct Quz; } #[doc(hidden)] pub mod hidden { pub struct Bar; } #[macro_export] macro_rules! foo { () => {} } ``` It generates: ```json { "foo/macro.foo!.html": "foo/macro.foo.html", "foo/private/struct.Quz.html": "foo/struct.Quz.html", "foo/hidden/struct.Bar.html": "foo/struct.Bar.html" } ``` Do the pathes look as you expected ````@pietroalbini?```` r? ````@jyn514````
2021-03-01Move lint machinery into a separate fileJoshua Nelson-0/+1
2021-03-01Rename rustdoc lints to be a tool lint instead of built-in.Joshua Nelson-0/+1
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests Otherwise, all `rustdoc::` lints would be ignored. - Register all existing lints as removed This unfortunately doesn't work with `register_renamed` because tool lints have not yet been registered when rustc is running. For similar reasons, `check_backwards_compat` doesn't work either. Call `register_removed` directly instead. - Fix fallout + Rustdoc lints for compiler/ + Rustdoc lints for library/ Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for `rustdoc::intra_doc_link_resolution_failure`, since there was no time when the latter was valid.
2021-03-02Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514Guillaume Gomez-0/+1
Check stability and feature attributes in rustdoc Fixes #82588. cc `@Nemo157` `@camelid` r? `@jyn514`
2021-03-02Rollup merge of #82018 - jyn514:no-dummy-cache, r=camelid,GuillaumeGomezGuillaume Gomez-6/+6
Remove the dummy cache in `DocContext`; delete RenderInfo The same information is available everywhere; the only reason the dummy cache was needed is because it was previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it also completely removes `RenderInfo`. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RenderInfo altogether Helps with https://github.com/rust-lang/rust/pull/82014. The next step is to move the `populate()` call before the `collect_intra_doc_links` pass, which currently breaks because a) lots of the cache is populated in early passes, and b) intra_doc_links itself sets some info with `register_res`. I'm working on separate PR for that to avoid making too many big changes at once. r? `@GuillaumeGomez`
2021-03-02Rollup merge of #81932 - jyn514:rustdoc-logging, r=Mark-SimulacrumGuillaume Gomez-0/+74
Always compile rustdoc with debug logging enabled when `download-rustc` is set Previously, logging at DEBUG or below would always be silenced, because rustc compiles tracing with the `static_max_level_info` feature. That makes sense for release artifacts, but not for developing rustdoc. Instead, this compiles two different versions of tracing: one in the release artifacts, distributed in the sysroot, and a new version compiled by rustdoc. Since `rustc_driver` is always linked to the version of sysroot, this copy/pastes `init_env_logging` into rustdoc. To avoid compiling an unnecessary version of tracing when `download-rustc` isn't set, this adds a new `using-ci-artifacts` feature for rustdoc and passes that feature in bootstrap. Addresses https://github.com/rust-lang/rust/issues/81930. This builds on https://github.com/rust-lang/rust/pull/79540. r? `@Mark-Simulacrum`
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-6/+6
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-28Always compile rustdoc with debug logging enabled when `download-rustc` is setJoshua Nelson-0/+74
Previously, logging at DEBUG or below would always be silenced, because rustc compiles tracing with the `static_max_level_info` feature. That makes sense for release artifacts, but not for developing rustdoc. Instead, this compiles two different versions of tracing: one in the release artifacts, distributed in the sysroot, and a new version compiled by rustdoc. Since `rustc_driver` is always linked to the version of sysroot, this copy/pastes `init_env_logging` into rustdoc. The builds the second version of tracing unconditionally; see the code for details on why.
2021-02-28Run some rustc passes in rustdocGuillaume Gomez-0/+1
2021-02-26Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-seGuillaume Gomez-1/+0
Stabilize str_split_once Closes #74773
2021-02-23Add --generate-redirect-map option to replace HTML redirection file with a ↵Guillaume Gomez-0/+7
unique JSON map
2021-02-19Rollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514Dylan DPC-1/+4
rustdoc: Support argument files Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.: rustdoc `@argfile` This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments. The feature was stabilized for `rustc` in #66172.
2021-02-19rustdoc: Support argument filesMiguel Ojeda-1/+4
Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.: rustdoc @argfile This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments. The feature was stabilized for `rustc` in #66172. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-09Stabilize str_split_onceJacob Pratt-1/+0
2021-02-06Rollup merge of #80011 - Stupremee:stabilize-peekable-next-if, r=dtolnayMara Bos-1/+0
Stabilize `peekable_next_if` This PR stabilizes the `peekable_next_if` feature Resolves #72480
2021-02-02Rollup merge of #81492 - camelid:rustdoc-internal-mod-vis, r=GuillaumeGomezJonas Schievink-1/+2
rustdoc: Note why `rustdoc::html::markdown` is public Almost all of the modules are crate-private, except for `rustdoc::json::types`, which I believe is intended to be for public use; and `rustdoc::html::markdown`, which is used externally by the error-index generator and so has to be public. r? ``@GuillaumeGomez``
2021-01-31rustdoc: Note why `rustdoc::html::markdown` is publicCamelid-1/+2
Almost all of the modules are crate-private, except for `rustdoc::json::types`, which I believe is intended to be for public use; and `rustdoc::html::markdown`, which is used externally by the error-index generator and so has to be public.
2021-01-28rustdoc: Remove unnecessary optionalCamelid-2/+2
Previously, the HTML output format was represented by both `Some(OutputFormat::Html)` and `None` so there's no need to have an optional. Instead, `OutputFormat::Html` is explicitly the default and we no longer have a "tri-state enum".
2021-01-24Rollup merge of #81264 - Swatinem:doctest-run-directory, r=jyn514Jonas Schievink-0/+8
Add unstable option to control doctest run directory This option will allow splitting the compile-time from the run-time directory of doctest invocations and is one step to solve https://github.com/rust-lang/cargo/issues/8993#issuecomment-760088944 r? `@jyn514`
2021-01-23Rollup merge of #81275 - jyn514:time-render, r=wesleywiserJonas Schievink-1/+1
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 option to control doctest run directoryArpad Borsos-0/+8
This option will allow splitting the compile-time from the run-time directory of doctest invocations and is one step to solve https://github.com/rust-lang/cargo/issues/8993#issuecomment-760088944
2021-01-23Calculate self-profile strings in `Compiler::enter` instead in codegenJoshua Nelson-6/+3
This avoids each tool having to separately find and call `self_profile_alloc_strings`. - Don't compute the global context if it hasn't yet been computed This avoids giving extraneous errors about unresolved names if an error occurs during parsing.
2021-01-22Fix <unknown> queriesJoshua Nelson-2/+5
This happened because `alloc_query_strings` was never called.
2021-01-21Deny internal lints for rustdocJoshua Nelson-0/+1
2021-01-21Fix rustc::internal lints on rustdocJoshua Nelson-2/+2
2021-01-13Auto merge of #77858 - ijackson:split-inclusive, r=KodrAusbors-1/+0
Stabilize split_inclusive ### Contents of this MR This stabilises: * `slice::split_inclusive` * `slice::split_inclusive_mut` * `str::split_inclusive` Closes #72360. ### A possible concern The proliferation of `split_*` methods is not particularly pretty. The existence of `split_inclusive` seems to invite the addition of `rsplit_inclusive`, `splitn_inclusive`, etc. We could instead have a more general API, along these kinds of lines maybe: ``` pub fn split_generic('a,P,H>(&'a self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; pub fn split_generic_mut('a,P,H>(&'a mut self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; trait SplitHow { fn reverse(&self) -> bool; fn inclusive -> bool; fn limit(&self) -> Option<usize>; } pub struct SplitFwd; ... pub struct SplitRevInclN(pub usize); ``` But maybe that is worse. ### Let us defer that? ### This seems like a can of worms. I think we can defer opening it now; if and when we have something more general, these two methods can become convenience aliases. But I thought I would mention it so the lang API team can consider it and have an opinion.
2021-01-12Update help message and add regression testTristan Dannenberg-6/+1
2021-01-12Fix rustdoc --test-builder argument parsingTristan Dannenberg-2/+3
2021-01-04Remove two obsolete uses of #![feature(split_inclusive)]Ian Jackson-1/+0
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-12-30Add Iterator::intersperseJonas Schievink-0/+1
2020-12-27Auto merge of #79642 - ijackson:default-theme-stab, r=jyn514bors-2/+2
rustdoc: stabilise --default-theme command line option As discussed in #77213, this seems like it has bedded in and can be safely and usefully made stable. (rustdoc already has other stable options that interact quite intimately with the rustdoc-supplied CSS, and also an option for supplying entirely different CSS, so exposing the theme names this way seems a very minor step.) There is also a commit to do some minor grammar fixes to the help message.
2020-12-17Fix rebase conflictJoshua Nelson-4/+0
2020-12-17TODO -> FIXMEJoshua Nelson-1/+1
2020-12-17Make it compileJoshua Nelson-4/+5
2020-12-17[tmp] Pass `TyCtxt` through to the render backendJoshua Nelson-8/+5
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-17Move `run_renderer` into the main `global_ctxt` closureJoshua Nelson-25/+78
2020-12-15Remove redundant assignmentJoshua Nelson-5/+0
`crate.name` is already set by `tcx.crate_name`, there's no need to override it.
2020-12-13Use imports instead of rewriting the type signature of `stable`Joshua Nelson-14/+2
This was an adventure; see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/'higher.20ranked.20subtype.20error'