diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-20 23:37:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-20 23:37:32 +0100 |
| commit | aa7f4520a1d5fc634f80a6ebe532fe2bdfa52501 (patch) | |
| tree | 3848647bb2e7c33f7b9684a2ad9ebf5b58801f8e /src | |
| parent | 530c884372cbee0ab81df404c90b0bc3b551a474 (diff) | |
| parent | 06b00ad19972c18150fe25a9b3716ffdf5300a83 (diff) | |
| download | rust-aa7f4520a1d5fc634f80a6ebe532fe2bdfa52501.tar.gz rust-aa7f4520a1d5fc634f80a6ebe532fe2bdfa52501.zip | |
Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddle
Fix star handling in block doc comments Fixes #92872. Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in: ```rust /// he /** * hello */ #[doc = "boom"] ``` We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars. r? ``@camelid``
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc/strip-block-doc-comments-stars.docblock.html | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/strip-block-doc-comments-stars.rs | 11 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7ae7b940f26..993503005d7 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1041,9 +1041,9 @@ impl Attributes { ) -> Attributes { let mut doc_strings: Vec<DocFragment> = vec![]; let clean_attr = |(attr, parent_module): (&ast::Attribute, Option<DefId>)| { - if let Some(value) = attr.doc_str() { + if let Some((value, kind)) = attr.doc_str_and_comment_kind() { trace!("got doc_str={:?}", value); - let value = beautify_doc_string(value); + let value = beautify_doc_string(value, kind); let kind = if attr.is_doc_comment() { DocFragmentKind::SugaredDoc } else { diff --git a/src/test/rustdoc/strip-block-doc-comments-stars.docblock.html b/src/test/rustdoc/strip-block-doc-comments-stars.docblock.html new file mode 100644 index 00000000000..22b0b5dc47e --- /dev/null +++ b/src/test/rustdoc/strip-block-doc-comments-stars.docblock.html @@ -0,0 +1,2 @@ +<div class="docblock"><p>a</p> +</div> \ No newline at end of file diff --git a/src/test/rustdoc/strip-block-doc-comments-stars.rs b/src/test/rustdoc/strip-block-doc-comments-stars.rs new file mode 100644 index 00000000000..ed2297b4fac --- /dev/null +++ b/src/test/rustdoc/strip-block-doc-comments-stars.rs @@ -0,0 +1,11 @@ +#![crate_name = "foo"] + +// The goal of this test is to answer that it won't be generated as a list because +// block doc comments can have their lines starting with a star. + +// @has foo/fn.foo.html +// @snapshot docblock - '//*[@class="rustdoc-toggle top-doc"]//*[@class="docblock"]' +/** + * a + */ +pub fn foo() {} |
