diff options
| author | bors <bors@rust-lang.org> | 2021-07-14 18:36:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-14 18:36:44 +0000 |
| commit | e87188c252a3b6dea8ed54d7915fbc2cfb61443b (patch) | |
| tree | d1a7dcc583bbe747a2b06f9d31d45f13a65da0f3 /src/librustdoc | |
| parent | 4f0c568785adcc0a123cac9d47047020b7a24821 (diff) | |
| parent | ac6672b74631cfcdbfd042724e29969b193cefa1 (diff) | |
Auto merge of #87133 - GuillaumeGomez:rollup-pfz9jbk, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #87027 (expand: Support helper attributes for built-in derive macros) - #87056 (Fix codeblocks overflow) - #87117 (Shrink the CrateStore dynamic interface.) - #87120 (rustdoc: Remove unnecessary `extern crate` aliases) - #87125 (Fix Ayu theme `<code>` color) - #87130 (Update browser-ui-test package version) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/doctest.rs | 20 | ||||
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 51 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/themes/ayu.css | 2 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/markdown.rs | 4 |
6 files changed, 47 insertions, 36 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index cd914f05e68..c5ca396e720 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -167,11 +167,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> { test_args.insert(0, "rustdoctest".to_string()); - testing::test_main( - &test_args, - tests, - Some(testing::Options::new().display_output(display_warnings)), - ); + test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings))); // Collect and warn about unused externs, but only if we've gotten // reports for each doctest @@ -769,7 +765,7 @@ crate trait Tester { } crate struct Collector { - crate tests: Vec<testing::TestDescAndFn>, + crate tests: Vec<test::TestDescAndFn>, // The name of the test displayed to the user, separated by `::`. // @@ -930,22 +926,22 @@ impl Tester for Collector { }; debug!("creating test {}: {}", name, test); - self.tests.push(testing::TestDescAndFn { - desc: testing::TestDesc { - name: testing::DynTestName(name), + self.tests.push(test::TestDescAndFn { + desc: test::TestDesc { + name: test::DynTestName(name), ignore: match config.ignore { Ignore::All => true, Ignore::None => false, Ignore::Some(ref ignores) => ignores.iter().any(|s| target_str.contains(s)), }, // compiler failures are test failures - should_panic: testing::ShouldPanic::No, + should_panic: test::ShouldPanic::No, allow_fail: config.allow_fail, compile_fail: config.compile_fail, no_run, - test_type: testing::TestType::DocTest, + test_type: test::TestType::DocTest, }, - testfn: testing::DynTestFn(box move || { + testfn: test::DynTestFn(box move || { let report_unused_externs = |uext| { unused_externs.lock().unwrap().push(uext); }; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 9fff508165a..3b599e4997a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -33,6 +33,7 @@ use std::str; use crate::clean::RenderedLink; use crate::doctest; +use crate::html::escape::Escape; use crate::html::highlight; use crate::html::toc::TocBuilder; @@ -207,26 +208,11 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { let should_panic; let ignore; let edition; - if let Some(Event::Start(Tag::CodeBlock(kind))) = event { - let parse_result = match kind { - CodeBlockKind::Fenced(ref lang) => { - LangString::parse_without_check(&lang, self.check_error_codes, false) - } - CodeBlockKind::Indented => Default::default(), - }; - if !parse_result.rust { - return Some(Event::Start(Tag::CodeBlock(kind))); - } - compile_fail = parse_result.compile_fail; - should_panic = parse_result.should_panic; - ignore = parse_result.ignore; - edition = parse_result.edition; + let kind = if let Some(Event::Start(Tag::CodeBlock(kind))) = event { + kind } else { return event; - } - - let explicit_edition = edition.is_some(); - let edition = edition.unwrap_or(self.edition); + }; let mut origtext = String::new(); for event in &mut self.inner { @@ -241,6 +227,35 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { let lines = origtext.lines().filter_map(|l| map_line(l).for_html()); let text = lines.collect::<Vec<Cow<'_, str>>>().join("\n"); + let parse_result = match kind { + CodeBlockKind::Fenced(ref lang) => { + let parse_result = + LangString::parse_without_check(&lang, self.check_error_codes, false); + if !parse_result.rust { + return Some(Event::Html( + format!( + "<div class=\"example-wrap\">\ + <pre{}>{}</pre>\ + </div>", + format!(" class=\"language-{}\"", lang), + Escape(&text), + ) + .into(), + )); + } + parse_result + } + CodeBlockKind::Indented => Default::default(), + }; + + compile_fail = parse_result.compile_fail; + should_panic = parse_result.should_panic; + ignore = parse_result.ignore; + edition = parse_result.edition; + + let explicit_edition = edition.is_some(); + let edition = edition.unwrap_or(self.edition); + let playground_button = self.playground.as_ref().and_then(|playground| { let krate = &playground.crate_name; let url = &playground.url; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 66dfd2fac84..208e8f723f4 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -435,7 +435,7 @@ nav.sub { border-bottom-left-radius: 5px; } -.rustdoc:not(.source) .example-wrap > pre.rust { +.rustdoc:not(.source) .example-wrap > pre:not(.line-number) { width: 100%; overflow-x: auto; } diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 9da3fe07ade..8296c3f91ca 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -34,7 +34,7 @@ h4 { background: rgba(0, 0, 0, 0); } -code { +.docblock code { color: #ffb454; } h3 > code, h4 > code, h5 > code { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index bc635190f42..d4d87819c0d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -53,11 +53,11 @@ extern crate rustc_parse; extern crate rustc_passes; extern crate rustc_resolve; extern crate rustc_session; -extern crate rustc_span as rustc_span; +extern crate rustc_span; extern crate rustc_target; extern crate rustc_trait_selection; extern crate rustc_typeck; -extern crate test as testing; +extern crate test; #[cfg(feature = "jemalloc")] extern crate tikv_jemalloc_sys; diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 5da3a75e876..45966c0058d 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -136,10 +136,10 @@ crate fn test(mut options: Options) -> Result<(), String> { find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores, None); options.test_args.insert(0, "rustdoctest".to_string()); - testing::test_main( + test::test_main( &options.test_args, collector.tests, - Some(testing::Options::new().display_output(options.display_warnings)), + Some(test::Options::new().display_output(options.display_warnings)), ); Ok(()) } |
