about summary refs log tree commit diff
path: root/src/librustdoc/externalfiles.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-11/+11
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-3/+3
2023-09-17Don't emit an error if the `custom_code_classes_in_docs` feature is disabled ↵Guillaume Gomez-0/+4
when its syntax is used.
2023-08-16Use more named format argsGuillaume Gomez-1/+5
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-5/+3
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+2
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-7/+7
2022-03-04librustdoc: adopt let else in more placesest31-4/+1
2021-11-19rustdoc: Fix some unescaped HTML tags in docsNoah Lev-3/+3
They were being interpreted literally.
2021-10-04heading_level: u32 -> heading_offset: HeadingOffsetMukund Lakshman-3/+3
2021-10-04No need to default offset since we always override it.Mukund Lakshman-2/+2
2021-10-04Change `Markdown(...)` to `Markdown { ... }`Mukund Lakshman-2/+20
2021-10-04librustdoc: Use correct heading levels.Mukund Lakshman-2/+2
- Avoid multiple <h1>s on a page. - The <h#> tags should follow a semantic hierarchy. - Cap at h6 (no h7)
2021-06-20Use Tera templates for rustdoc.Jacob Hoffman-Andrews-1/+3
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.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-7/+7
This gives warnings about dead code.
2020-11-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-2/+2
The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no longer active nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - Add tests Check against `Cheat`, not whether nightly features are allowed. Nightly features are always allowed on the nightly channel. - Only call `is_nightly_build()` once within a function - Use booleans consistently for rustc_incremental Sessions can't be passed through threads, so `read_file` couldn't take a session. To be consistent, also take a boolean in `write_file_header`.
2020-07-15rustdoc: Rename internal API fns to `into_string`Lzu Tao-2/+2
to avoid surprising listed in API guidelines.
2020-01-10nix syntax::errors & prefer rustc_errors over errorsMazdak Farrokhzad-4/+3
2020-01-02Normalize `syntax::edition` imports.Mazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-21/+31
2019-11-30move UnstableFeatures -> rustc_featureMazdak Farrokhzad-1/+1
2019-08-11Reduce nesting in externalfiles implementationMark Rousskov-28/+14
Utilize `?` instead of and_then/map operators
2019-08-11Drop RefCell from IdMap in markdown renderingMark Rousskov-4/+2
2019-08-11Remove fmt::Display impls on Markdown structsMark Rousskov-2/+2
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-4/+4
2019-05-06set the default edition when pre-parsing a doctestQuietMisdreavus-3/+6
2019-02-23Transition librustdoc to 2018 editionHirokazu Hata-2/+3
2018-12-25Remove licensesMark Rousskov-10/+0
2018-11-04add Debug impls for the Options structsQuietMisdreavus-1/+1
2018-07-31Remove global derive_id and reset_ids functionsMark Rousskov-4/+8
Previously these functions relied on TLS but we can instead thread the relevant state through explicitly.
2018-07-31Further extract error code switchMark Rousskov-3/+5
Removes dependency on UnstableFeatures from markdown rendering
2018-05-14replace error/warning println with structured diagQuietMisdreavus-11/+14
2018-02-16Remove hoedown from rustdocGuillaume Gomez-4/+4
Is it really time? Have our months, no, *years* of suffering come to an end? Are we finally able to cast off the pall of Hoedown? The weight which has dragged us down for so long? ----- So, timeline for those who need to catch up: * Way back in December 2016, [we decided we wanted to switch out the markdown renderer](https://github.com/rust-lang/rust/issues/38400). However, this was put on hold because the build system at the time made it difficult to pull in dependencies from crates.io. * A few months later, in March 2017, [the first PR was done, to switch out the renderers entirely](https://github.com/rust-lang/rust/pull/40338). The PR itself was fraught with CI and build system issues, but eventually landed. * However, not all was well in the Rustdoc world. During the PR and shortly after, we noticed [some differences in the way the two parsers handled some things](https://github.com/rust-lang/rust/issues/40912), and some of these differences were major enough to break the docs for some crates. * A couple weeks afterward, [Hoedown was put back in](https://github.com/rust-lang/rust/pull/41290), at this point just to catch tests that Pulldown was "spuriously" running. This would at least provide some warning about spurious tests, rather than just breaking spontaneously. * However, the problems had created enough noise by this point that just a few days after that, [Hoedown was switched back to the default](https://github.com/rust-lang/rust/pull/41431) while we came up with a solution for properly warning about the differences. * That solution came a few weeks later, [as a series of warnings when the HTML emitted by the two parsers was semantically different](https://github.com/rust-lang/rust/pull/41991). But that came at a cost, as now rustdoc needed proc-macro support (the new crate needed some custom derives farther down its dependency tree), and the build system was not equipped to handle it at the time. It was worked on for three months as the issue stumped more and more people. * In that time, [bootstrap was completely reworked](https://github.com/rust-lang/rust/pull/43059) to change how it ordered compilation, and [the method by which it built rustdoc would change](https://github.com/rust-lang/rust/pull/43482), as well. This allowed it to only be built after stage1, when proc-macros would be available, allowing the "rendering differences" PR to finally land. * The warnings were not perfect, and revealed a few [spurious](https://github.com/rust-lang/rust/pull/44368) [differences](https://github.com/rust-lang/rust/pull/45421) between how we handled the renderers. * Once these were handled, [we flipped the switch to turn on the "rendering difference" warnings all the time](https://github.com/rust-lang/rust/pull/45324), in October 2017. This began the "warning cycle" for this change, and landed in stable in 1.23, on 2018-01-04. * Once those warnings hit stable, and after a couple weeks of seeing whether we would get any more reports than what we got from sitting on nightly/beta, [we switched the renderers](https://github.com/rust-lang/rust/pull/47398), making Pulldown the default but still offering the option to use Hoedown. And that brings us to the present. We haven't received more new issues from this in the meantime, and the "switch by default" is now on beta. Our reasoning is that, at this point, anyone who would have been affected by this has run into it already.
2018-01-23Auto merge of #47620 - GuillaumeGomez:multiple-themes, r=QuietMisdreavusbors-1/+1
Multiple themes for rustdoc r? @QuietMisdreavus
2018-01-22Add LinkReplacer pass for pulldownManish Goregaokar-2/+2
2018-01-21Add themes optionGuillaume Gomez-1/+1
2018-01-10Use the new fs_read_write functions in rustc internalsMatt Brubeck-9/+8
2017-09-28Migrate to eprint/eprintln macros where appropriate.Corey Farwell-7/+2
2017-05-08Add markdown-[before|after]-content optionsGuillaume Gomez-1/+11
2016-10-09Remove unnecessary `pub` function classifier.Corey Farwell-1/+1
2016-10-09Make `ExternalHtml::load` short-circuited.Corey Farwell-10/+16
2016-10-09Refactor away `load_or_return` macro.Corey Farwell-23/+26
2016-10-08Add doc comments describing fields on `externalfiles::ExternalHtml`.Corey Farwell-0/+6
2016-10-08Don't construct `PathBuf` ownership if we don't need it.Corey Farwell-3/+3
2016-03-22try! -> ?Jorge Aparicio-2/+2
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2015-03-23Add generic conversion traitsAaron Turon-1/+1
This commit: * Introduces `std::convert`, providing an implementation of RFC 529. * Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all in favor of the corresponding generic conversion traits. Consequently, various IO APIs now take `AsRef<Path>` rather than `AsPath`, and so on. Since the types provided by `std` implement both traits, this should cause relatively little breakage. * Deprecates many `from_foo` constructors in favor of `from`. * Changes `PathBuf::new` to take no argument (creating an empty buffer, as per convention). The previous behavior is now available as `PathBuf::from`. * De-stabilizes `IntoCow`. It's not clear whether we need this separate trait. Closes #22751 Closes #14433 [breaking-change]
2015-03-13Fallout of std::old_io deprecationAlex Crichton-3/+2
2015-03-04std: Deprecate std::old_io::fsAlex Crichton-5/+11
This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change.
2015-02-05cleanup: replace `as[_mut]_slice()` calls with deref coercionsJorge Aparicio-2/+2
2015-02-02`for x in xs.iter()` -> `for x in &xs`Jorge Aparicio-1/+1