-
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?
Conversation
9aea6c3 to
1c1e8f0
Compare
|
I don't think this is correct: we definitely don't want newlines in Display impls. Allowing line wrapping seems good, though. What if we make a minimal change: allow multiline doc comments, but only when the lines are not empty (which creates a paragraph break in Markdown). In those cases, we still error as we do now. Separately, we can see what people think is the most logical choice in those cases. Perhaps we could have an attribute that lets you pick between "insert newline" or "ignore everything after the paragraph break". I don't know, but that's a more involve discussion that needs to happen, and I don't want to block getting the newline problem fixed on that. |
|
@Manishearth Makes sense! I went off of the example in #44, which used newlines. Off the top of my head, clap concatenates with spaces with multiple lines of doc comments, for example I believe argh also concatenates with spaces and rustdoc preserves line breaks |
|
To be clear, you are interested in what I have now with multiline doc comments, but error on empty lines, right? For example /// all
/// good!
struct CoolStruct;
/// multi paragraph
///
/// Not allowed
struct CoolStruct; |
|
Yes, and the first one should produce the string |
|
Ah! I wasn't on the same page there, is this in line with what you're thinking? 1.) Outputs "all good!" /// all
/// good!
struct CoolStruct;2.) error, multiline is not allowed /// multi paragraph
///
/// Not allowed
struct CoolStruct;3.) "multi paragraph" #[ignore_extra_doc_attributes]
/// multi paragraph
///
/// Not allowed
struct CoolStruct; |
|
correct! |
dc022d8 to
7726201
Compare
Updated! Fixed up the example and the documentation as well. Let me know if you have anything else you'd like changed |
7726201 to
d9a92b3
Compare
| #[derive(Display)] | ||
| /// Really fancy first line with thing: {thing} | ||
| /// Really cool second line | ||
| struct HappyMultiLine { |
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
d9a92b3 to
c500245
Compare
| #[derive(Display)] | ||
| #[ignore_extra_doc_attributes] | ||
| /// multi | ||
| /// line | ||
| /// | ||
| /// new paragraph should be ignored | ||
| struct HappyMultilineWithIgnore; |
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
Good callout! Here's a new test covering that case
Output is "multi line"
63ce708 to
e561494
Compare
| /** | ||
| * block | ||
| * comment | ||
| */ | ||
| /** | ||
| * block | ||
| * comment2 | ||
| */ | ||
| DoubleBlock, |
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.
I just added test cases for several other edge cases
Question—is it appropriate to concatenate sequential block comments with spaces?
This outputs "block\ncomment block\ncomment2"
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.
Yes, I think so.
#44 requests multi line doc strings, and I've also wanted this myself, so figured may as well!
Since multiple doc comments caused a panic prior, this is backwards compatible. If
#[ignore_extra_doc_attributes]is there, the firstdocident continues to be displayed, otherwise each doc comment is joined by newlinesThe first doc comment is used as the span
closes #44