-
Notifications
You must be signed in to change notification settings - Fork 20
allow multi line doc strings #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,53 @@ struct HappyStruct { | |
| #[derive(Display)] | ||
| #[ignore_extra_doc_attributes] | ||
| /// Just a basic struct {thing} | ||
| /// and this line should get ignored | ||
| /// and this line should not get ignored | ||
| struct HappyStruct2 { | ||
| thing: &'static str, | ||
| } | ||
|
|
||
| #[derive(Display)] | ||
| /// Really fancy first line with thing: {thing} | ||
| /// Really cool second line | ||
| struct HappyMultiLine { | ||
| thing: &'static str, | ||
| } | ||
|
|
||
| #[derive(Display)] | ||
| #[ignore_extra_doc_attributes] | ||
| /// multi | ||
| /// line | ||
| /// | ||
| /// new paragraph should be ignored | ||
| struct HappyMultilineWithIgnore; | ||
|
Comment on lines
+27
to
+33
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good callout! Here's a new test covering that case Output is |
||
|
|
||
| #[derive(Display)] | ||
| enum MixedBlockAndLineComments { | ||
| /** | ||
| * hello | ||
| * block | ||
| * comment | ||
| */ | ||
| /// line comment | ||
| BlockFirst, | ||
| /// line comment | ||
| /** | ||
| * hello | ||
| * block | ||
| * comment | ||
| */ | ||
| LineFirst, | ||
| /** | ||
| * block | ||
| * comment | ||
| */ | ||
| /** | ||
| * block | ||
| * comment2 | ||
| */ | ||
| DoubleBlock, | ||
|
Comment on lines
+51
to
+59
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just added test cases for several other edge cases Question—is it appropriate to concatenate sequential block comments with spaces? This outputs
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think so. |
||
| } | ||
|
|
||
| #[derive(Display)] | ||
| enum Happy { | ||
| /// I really like Variant1 | ||
|
|
@@ -109,7 +151,30 @@ fn does_it_print() { | |
| ); | ||
| assert_display(HappyStruct { thing: "hi" }, "Just a basic struct hi"); | ||
|
|
||
| assert_display(HappyStruct2 { thing: "hi2" }, "Just a basic struct hi2"); | ||
| assert_display( | ||
| HappyStruct2 { thing: "hi2" }, | ||
| "Just a basic struct hi2 and this line should not get ignored", | ||
| ); | ||
|
|
||
| assert_display( | ||
| HappyMultiLine { thing: "rust" }, | ||
| "Really fancy first line with thing: rust Really cool second line", | ||
| ); | ||
|
|
||
| assert_display(HappyMultilineWithIgnore, "multi line"); | ||
|
|
||
| assert_display( | ||
| MixedBlockAndLineComments::BlockFirst, | ||
| "hello\nblock\ncomment line comment", | ||
| ); | ||
| assert_display( | ||
| MixedBlockAndLineComments::LineFirst, | ||
| "line comment hello\nblock\ncomment", | ||
| ); | ||
| assert_display( | ||
| MixedBlockAndLineComments::DoubleBlock, | ||
| "block\ncomment block\ncomment2", | ||
| ); | ||
|
|
||
| assert_display(inner_mod::InnerHappy::Variant1, "I really like Variant1"); | ||
| assert_display( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,10 @@ enum TestType { | |
|
|
||
| /// Multi | ||
| /// line | ||
| /// doc. | ||
| /// doc | ||
| /// is | ||
| /// pretty | ||
| /// swell | ||
| Variant2, | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use displaydoc::Display; | ||
|
|
||
| #[derive(Display)] | ||
| /// Multi | ||
| /// line | ||
| /// doc | ||
| /// with | ||
| /// line | ||
| /// break | ||
| /// | ||
| /// is | ||
| /// pretty | ||
| /// not | ||
| /// swell | ||
| /// 😞👊 | ||
| struct TestType; | ||
|
|
||
| static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| error: proc-macro derive panicked | ||
| --> tests/ui/multi_line.rs:4:10 | ||
| --> tests/ui/multi_line_line_break.rs:3:10 | ||
| | | ||
| 4 | #[derive(Display)] | ||
| 3 | #[derive(Display)] | ||
| | ^^^^^^^ | ||
| | | ||
| = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive. | ||
| = help: message: Line breaks in multi-line doc comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive | ||
|
|
||
| error[E0277]: `TestType` doesn't implement `std::fmt::Display` | ||
| --> tests/ui/multi_line.rs:15:37 | ||
| --> tests/ui/multi_line_line_break.rs:18:37 | ||
| | | ||
| 15 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| 18 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| | ^^^^^^^^ unsatisfied trait bound | ||
| | | ||
| help: the trait `std::fmt::Display` is not implemented for `TestType` | ||
| --> tests/ui/multi_line.rs:5:1 | ||
| --> tests/ui/multi_line_line_break.rs:16:1 | ||
| | | ||
| 5 | enum TestType { | ||
| | ^^^^^^^^^^^^^ | ||
| 16 | struct TestType; | ||
| | ^^^^^^^^^^^^^^^ | ||
| note: required by a bound in `assert_impl_all` | ||
| --> tests/ui/multi_line.rs:15:1 | ||
| --> tests/ui/multi_line_line_break.rs:18:1 | ||
| | | ||
| 15 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| 18 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` | ||
| = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| use displaydoc::Display; | ||
|
|
||
| #[derive(Display)] | ||
| /** | ||
| * block | ||
| */ | ||
| /** | ||
| * | ||
| */ | ||
| struct TestType; | ||
|
|
||
| static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| error: proc-macro derive panicked | ||
| --> tests/ui/multi_line_line_break_block.rs:3:10 | ||
| | | ||
| 3 | #[derive(Display)] | ||
| | ^^^^^^^ | ||
| | | ||
| = help: message: Line breaks in multi-line doc comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive | ||
|
|
||
| error[E0277]: `TestType` doesn't implement `std::fmt::Display` | ||
| --> tests/ui/multi_line_line_break_block.rs:12:37 | ||
| | | ||
| 12 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| | ^^^^^^^^ unsatisfied trait bound | ||
| | | ||
| help: the trait `std::fmt::Display` is not implemented for `TestType` | ||
| --> tests/ui/multi_line_line_break_block.rs:10:1 | ||
| | | ||
| 10 | struct TestType; | ||
| | ^^^^^^^^^^^^^^^ | ||
| note: required by a bound in `assert_impl_all` | ||
| --> tests/ui/multi_line_line_break_block.rs:12:1 | ||
| | | ||
| 12 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` | ||
| = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: please include a test for multiline attributes with ignore_extra_doc_attributes