about summary refs log tree commit diff
path: root/src/librustdoc/html/sources.rs
AgeCommit message (Collapse)AuthorLines
2021-09-16Auto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomezbors-1/+1
rustdoc: reduce number of copies when using parallel IO This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason. Helps with https://github.com/rust-lang/rust/issues/82741. Follow-up to https://github.com/rust-lang/rust/pull/60971.
2021-08-31some low hanging clippy::perf fixesMatthias Krüger-4/+3
2021-08-26Remove unnecessary copies when using parallel IOJoshua Nelson-1/+1
Previously, rustdoc was making lots of copies of temporary owned values. Now, it uses the owned value wherever possible.
2021-08-05Remove LightSpan and use Span directlyGuillaume Gomez-13/+11
2021-08-05Move extra arguments for highlight URL generation into a new ContextInfo ↵Guillaume Gomez-3/+1
struct for better readability
2021-08-05Add links on source types to go to definitionGuillaume Gomez-45/+131
2021-06-20Use Tera templates for rustdoc.Jacob Hoffman-Andrews-0/+1
Replaces a format!() call in layout::render with a template expansion. Introduces a `templates` field in SharedContext so parts of rustdoc can share pre-rendered templates. This currently builds in a copy of the single template available, like with static files. However, future work can make this live-loadable with a perma-unstable flag, to make rustdoc developers' work easier.
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-3/+13
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-10Fix line number not being clickable on source pagesGuillaume Gomez-4/+5
2021-05-05Use local and remapped paths where appropriateAndy Wang-3/+7
2021-05-05Make local_path in RealFileName::Remapped Option to be removed in exported ↵Andy Wang-1/+7
metadata
2021-05-03Change librustdoc write(.. \n) to writeln(..); fix comment in grammarmautamu-1/+1
More grammar
2021-04-24Get rid of `item.span`Joshua Nelson-4/+4
- Remove `span` field, adding `Item::span()` instead - Special-case `Impl` and `Module` items - Use dummy spans for primitive items
2021-04-24Do the hard part firstJoshua Nelson-3/+3
The only bit failing was the module, so change that before removing the `span` field.
2021-04-22Remove unnecessary `edition` field on SharedContextJoshua Nelson-1/+1
2021-03-23rustdoc: Use diagnostics for error when including sourcesCamelid-5/+3
This error probably almost never happens, but we should still use the diagnostic infrastructure. My guess is that the error was added back before rustdoc used the rustc diagnostic infrastructure (it was all `println!` and `eprintln!` back then!) and since it likely rarely occurs and this code doesn't change that much, no one thought to transition it to using diagnostics. Note that the old error was actually a warning (it didn't stop the rest of doc building). It seems very unlikely that this would fail without the rest of the doc build failing, so it makes more sense for it to be a hard error. The error looks like this: error: failed to render source code for `src/test/rustdoc/smart-punct.rs`: "bar": foo --> src/test/rustdoc/smart-punct.rs:3:1 | 3 | / #![crate_name = "foo"] 4 | | 5 | | //! This is the "start" of the 'document'! How'd you know that "it's" ... 6 | | //! ... | 22 | | //! I say "don't smart-punct me -- please!" 23 | | //! ``` | |_______^ I wasn't sure how to trigger the error, so to create that message I temporarily made rustdoc always emit it. That's also why it says "bar" and "foo" instead of a real error message. Note that the span of the diagnostic starts at line 3 because line 1 of that file is a (non-doc) comment and line 2 is a blank line.
2021-03-21Rename `clean::Item.source` to `span`Camelid-3/+3
Its type is called `clean::Span`, and also the name in the rest of rustdoc and rustc for this kind of field is `span`.
2021-02-16Make `Clean` take &mut DocContextJoshua Nelson-2/+2
- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics` - Take `&mut DocContext` in most of `clean` - Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad. - Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.
2021-01-30rustdoc tweakingbors-8/+6
* Reuse memory * simplify `next_def_id`, avoid multiple hashing and unnecessary lookups * remove `all_fake_def_ids`, use the global map instead (probably not a good step toward parallelization, though...) * convert `add_deref_target` to iterative implementation * use `ArrayVec` where we know the max number of elements * minor touchups here and there * avoid building temporary vectors that get appended to other vectors At most places I may or may not be doing the compiler's job is this PR.
2020-12-24rustdoc: Highlight edition-specific keywords correctly in code blocks, ↵ThePuzzlemaker-3/+4
accounting for code block edition modifiers This is a squash of these commits: - Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers - Fix unit tests - Revert changes to rustc_span::symbol to prepare for merge of #80272 - Use new Symbol::is_reserved API from #80272 - Remove unused import added by accident when merging
2020-12-17Make it compileJoshua Nelson-6/+6
2020-12-15Use `Symbol`s for crate namesJoshua Nelson-1/+1
2020-12-12Calculate span info on-demand instead of ahead of timeJoshua Nelson-4/+13
This should *vastly* reduce memory usage.
2020-11-22Make `fold_item_recur` non-nullableJoshua Nelson-1/+1
This gets rid of a bunch of `unwrap()`s and makes it a little more clear what's going on. Originally I wanted to make `fold_item` non-nullable too, which would have been a lot nicer to work with, but unfortunately `stripper` does actually return `None` in some places. I might make a follow-up moving stripper to be special and not a pass so that passes can be non-nullable.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-1/+1
This gives warnings about dead code.
2020-10-20Apply some review suggestionsCamelid-5/+5
2020-10-18rustdoc: Show the correct source filename, without `.html`Camelid-9/+8
Previously the title would be lib.rs.html -- source if `lib.rs` was the actual source filename. Now the title is lib.rs – source (note the en dash).
2020-08-31Fix strings indentGuillaume Gomez-1/+1
2020-07-27Move `Error` and `RenderInfo` out of `html` moduleJoseph Ryan-1/+2
2020-07-14rustdoc: glue tokens before highlightingAndy Russell-5/+6
Fixes #72684. This commit also modifies the signature of `Classifier::new` to avoid copying the source being highlighted.
2020-07-12Clean up handling of style files in rustdocJarek Samic-1/+1
Disable all themes other than `light.css` to prevent rule conflicts
2020-06-09Fix more clippy warningsMatthias Krüger-1/+1
Fixes more of: clippy::unused_unit clippy::op_ref clippy::useless_format clippy::needless_return clippy::useless_conversion clippy::bind_instead_of_map clippy::into_iter_on_ref clippy::redundant_clone clippy::nonminimal_bool clippy::redundant_closure clippy::option_as_ref_deref clippy::len_zero clippy::iter_cloned_collect clippy::filter_next
2020-05-29Split payload of FileName::Real to track both real and virutalized paths.Felix S. Klock II-2/+2
Such splits arise from metadata refs into libstd. This way, we can (in a follow on commit) continue to emit the virtual name into things like the like the StableSourceFileId that ends up in incremetnal build artifacts, while still using the devirtualized file path when we want to access the file. Note that this commit is intended to be a refactoring; the actual fix to the bug in question is in a follow-on commit.
2020-04-08rustdoc: Don't try to load source files from external cratesOliver Middleton-2/+3
Local items defined in external macros shouldn't generate rendered source files and should link to the external crate's docs instead.
2020-03-10Store `TokenStream` in `rmeta::MacroDef`.Mazdak Farrokhzad-1/+1
This removes a hack from `load_macro_untracked` in which parsing is used.
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-29/+30
2019-09-07Move Source to BufferMark Rousskov-14/+7
2019-09-07layout::render takes Print instead of fmt::DisplayMark Rousskov-1/+2
2019-09-07De-indent all fmt::Display impls for later replacement to functionsMark Rousskov-17/+17
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 constant parameters to render to Layout structMark Rousskov-3/+1
2019-09-07Create buffers in top-level renderingMark Rousskov-4/+2
This avoids needlessly creating and threading the buffers through when we only use them once.
2019-09-07Migrate top-level rendering to BufferMark Rousskov-6/+4
2019-08-26Move source HTML generation to own moduleMark Rousskov-0/+187