From f67585d494fd92347e4954a240ddde14dcbd711b Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 18 Jun 2021 17:47:05 -0700 Subject: [PATCH] Update test cases for intra-doc links in summaries --- src/librustdoc/html/markdown/tests.rs | 4 +++- src/test/rustdoc-js/summaries.js | 2 +- src/test/rustdoc-js/summaries.rs | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index ac3ea4c8c5f6f..d10da64ccfaa5 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -221,7 +221,7 @@ fn test_header_ids_multiple_blocks() { #[test] fn test_short_markdown_summary() { fn t(input: &str, expect: &str) { - let output = short_markdown_summary(input); + let output = short_markdown_summary(input, &[][..]); assert_eq!(output, expect, "original: {}", input); } @@ -232,6 +232,7 @@ fn test_short_markdown_summary() { t("Hard-break \nsummary", "Hard-break summary"); t("hello [Rust] :)\n\n[Rust]: https://www.rust-lang.org", "hello Rust :)"); t("hello [Rust](https://www.rust-lang.org \"Rust\") :)", "hello Rust :)"); + t("dud [link]", "dud [link]"); t("code `let x = i32;` ...", "code let x = i32; …"); t("type `Type<'static>` ...", "type Type<'static> …"); t("# top header", "top header"); @@ -259,6 +260,7 @@ fn test_plain_text_summary() { t("Hard-break \nsummary", "Hard-break summary"); t("hello [Rust] :)\n\n[Rust]: https://www.rust-lang.org", "hello Rust :)"); t("hello [Rust](https://www.rust-lang.org \"Rust\") :)", "hello Rust :)"); + t("dud [link]", "dud [link]"); t("code `let x = i32;` ...", "code `let x = i32;` …"); t("type `Type<'static>` ...", "type `Type<'static>` …"); t("# top header", "top header"); diff --git a/src/test/rustdoc-js/summaries.js b/src/test/rustdoc-js/summaries.js index f175e47342df6..dfb11e80414c1 100644 --- a/src/test/rustdoc-js/summaries.js +++ b/src/test/rustdoc-js/summaries.js @@ -5,7 +5,7 @@ const QUERY = ['summaries', 'summaries::Sidebar', 'summaries::Sidebar2']; const EXPECTED = [ { 'others': [ - { 'path': '', 'name': 'summaries', 'desc': 'This summary has a link and code.' }, + { 'path': '', 'name': 'summaries', 'desc': 'This summary has a link, [code], and Sidebar2 intra-doc.' }, ], }, { diff --git a/src/test/rustdoc-js/summaries.rs b/src/test/rustdoc-js/summaries.rs index beb91e286b610..418c9f8d0edd0 100644 --- a/src/test/rustdoc-js/summaries.rs +++ b/src/test/rustdoc-js/summaries.rs @@ -1,9 +1,11 @@ #![crate_type = "lib"] #![crate_name = "summaries"] -//! This *summary* has a [link] and `code`. +//! This *summary* has a [link], [`code`], and [`Sidebar2`] intra-doc. //! -//! This is the second paragraph. +//! This is the second paragraph. It should not be rendered. +//! To test that intra-doc links are resolved properly, [`code`] should render +//! the square brackets, and [`Sidebar2`] should not. //! //! [link]: https://example.com