about summary refs log tree commit diff
path: root/src/librustdoc/markdown.rs
AgeCommit message (Collapse)AuthorLines
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-1/+1
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-09-17Update src/librustdoc/markdown.rsManish Goregaokar-1/+1
Co-authored-by: Michael Howell <michael@notriddle.com>
2023-09-17Don't emit an error if the `custom_code_classes_in_docs` feature is disabled ↵Guillaume Gomez-1/+13
when its syntax is used.
2023-08-16Use more named format argsGuillaume Gomez-5/+7
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-5/+5
2023-02-06Turn MarkdownWithToc into a struct with named fieldsGuillaume Gomez-1/+8
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-10-19Avoid cloning `RenderOptions`.Nicholas Nethercote-1/+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-19Clean up rustdoc startup.Nicholas Nethercote-2/+3
rustc's startup has several layers, including: - `interface::run_compiler` passes a closure, `f`, to `run_in_thread_pool_with_globals`, which creates a thread pool, sets up session globals, and passes `f` to `create_compiler_and_run`. - `create_compiler_and_run` creates a `Session`, a `Compiler`, sets the source map, and calls `f`. rustdoc is a bit different. - `main_args` calls `main_options` via `run_in_thread_pool_with_globals`, which (again) creates a thread pool (hardcoded to a single thread!) and sets up session globals. - `main_options` has four different paths. - The second one calls `interface::run_compiler`, which redoes the `run_in_thread_pool_with_globals`! This is bad. - The fourth one calls `interface::create_compiler_and_run`, which is reasonable. - The first and third ones don't do anything of note involving the above functions, except for some symbol interning which requires session globals. In other words, rustdoc calls into `rustc_interface` at three different levels. It's a bit confused, and feels like code where functionality has been added by different people at different times without fully understanding how the globally accessible stuff is set up. This commit tidies things up. It removes the `run_in_thread_pool_with_globals` call in `main_args`, and adjust the four paths in `main_options` as follows. - `markdown::test` calls `test::test_main`, which provides its own parallelism and so doesn't need a thread pool. It had one small use of symbol interning, which required session globals, but the commit removes this. - `doctest::run` already calls `interface::run_compiler`, so it doesn't need further adjustment. - `markdown::render` is simple but needs session globals for interning (which can't easily be removed), so it's now wrapped in `create_session_globals_then`. - The fourth path now uses `interface::run_compiler`, which is equivalent to the old `run_in_thread_pool_with_globals` + `create_compiler_and_run` pairing.
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-2/+2
2022-04-12Remove a `format` invocationRoc Yu-2/+3
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-12-12Rename `TestOptions` to `GlobalTestOptions`Noah Lev-2/+2
It seems to apply to all doctests in the crate.
2021-11-26Remove `--display-doctest-warnings`Joshua Nelson-7/+1
This can be replicated in full with other existing features, there's no need to have a separate option for it. This also fixes a bug where `--test-args=--show-output` had no effect, and updates the documentation.
2021-10-04heading_level: u32 -> heading_offset: HeadingOffsetMukund Lakshman-2/+4
2021-10-04Change `Markdown(...)` to `Markdown { ... }`Mukund Lakshman-1/+10
2021-10-04librustdoc: Use correct heading levels.Mukund Lakshman-1/+1
- Avoid multiple <h1>s on a page. - The <h#> tags should follow a semantic hierarchy. - Cap at h6 (no h7)
2021-09-14Rename --display-warnings to --display-doctest-warningsGuillaume Gomez-2/+2
2021-07-22Move calls to test_main into one functionGuillaume Gomez-8/+5
2021-07-18Add --nocapture option to rustdocGuillaume Gomez-0/+3
2021-07-13Remove renaming of `test` crateJoshua Nelson-2/+2
This is leftover from when `doctest` used to be called `test`. Remove it now, it's unnecessary and makes the code harder to read.
2021-06-21Don't reallocate the crate name when running doctestsJoshua Nelson-1/+2
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-2/+2
This gives warnings about dead code.
2020-11-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-3/+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-08-27Rename rustdoc/test -> rustdoc/doctestAleksey Kladov-1/+1
This modules contains the implementation of doctests, and not the tests of rustdoc itself. This name is confusing, so let's rename it to doctest for clarity.
2020-07-15rustdoc: Rename internal API fns to `into_string`Lzu Tao-2/+2
to avoid surprising listed in API guidelines.
2020-05-09End unification of exit codes in librustdocGuillaume Gomez-9/+4
2020-05-08Clean up rustdoc source codeGuillaume Gomez-27/+12
2020-04-23Create new rustdoc lint to check for code blocks tagsGuillaume Gomez-1/+1
2020-03-26Create output dir in rustdoc markdown renderTimothée Gerber-1/+6
2020-02-27use char instead of &str for single char patternsMatthias Krüger-1/+1
2020-02-04remove redundant imports (clippy::single_component_path_imports)Matthias Krüger-1/+0
2020-01-10nix syntax::errors & prefer rustc_errors over errorsMazdak Farrokhzad-3/+2
2020-01-02Normalize `syntax::edition` imports.Mazdak Farrokhzad-1/+1
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-17/+22
2019-11-30move UnstableFeatures -> rustc_featureMazdak Farrokhzad-1/+1
2019-09-11Rollup merge of #64072 - limira:patch-1, r=ollie27Mazdak Farrokhzad-1/+1
Replace file_stem by file_name in rustdoc markdown Before this PR, a file name like `some.file.md` will be output to a file named `some.html` with is not correct because the expected output file must be `some.file.html`
2019-09-04address rebase changesDario Gonzalez-1/+2
2019-09-03added feature gate enable-per-target-ignoresDario Gonzalez-1/+1
updated and augmented tests in html/markdown.rs
2019-09-02Replace file_stem by file_name in rustdoc markdownlimira-1/+1
2019-08-29Run doctests via out-of-process rustcAndreas Jonson-5/+2
2019-08-27Rollup merge of #62600 - emmericp:libtest-add-show-output, r=gnzlbgMazdak Farrokhzad-1/+1
libtest: add --show-output flag to print stdout of successful tests This pull request adds a new flag `--show-output` for tests to show the output of successful tests. For most formatters this was already supported just not exposed via the CLI (apparently only used by `librustdoc`). I've also added support for this option in the JSON formatter. This kind of fixes https://github.com/rust-lang/rust/issues/54669 which wants `--format json` to work with `--nocapture`, which is... well, impossible. What this issue really calls for is `--show-output` as implemented here.
2019-08-11Drop RefCell from IdMap in markdown renderingMark Rousskov-3/+2
2019-08-11Remove thread-local for playground configMark Rousskov-5/+6
2019-07-11libtest: add --show-output optionPaul Emmerich-1/+1
this new flag enables printing the captured stdout of successful tests utilizing the already existing display_output test runner option
2019-07-01Remove needless lifetimesJeremy Stucki-1/+1
2019-05-06set the default edition when pre-parsing a doctestQuietMisdreavus-3/+9
2019-04-22upgrade rustdoc's pulldown-cmark to 0.4.1Andy Russell-4/+3
2019-03-10Make the rustc driver and interface demand drivenJohn Kåre Alsaker-2/+2