-
Notifications
You must be signed in to change notification settings - Fork 161
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
Add get_documentation() to EnumMessage. #206
Conversation
Thanks for the PR. Just a couple of minor tweaks I think. I'm a little worried that people will mis-use this feature, and negatively impact the quaility of their own documentation, but I also see the practical benefit of something like this so I think it's okay. |
What are the minor tweaks you'd like to see? |
let params = params.clone(); | ||
// Push the documentation. | ||
documentation_arms | ||
.push(quote! { &#name::#ident #params => ::core::option::Option::Some(concat!(#( #documentation ),*).trim()) }); |
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.
Thoughts on concatenating vs using newlines? Obviously this won't be a full markdown parser, but I'm wondering if just concatenating lines is too simple.
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.
To make this friendlier to markup, I remove the leading space from each line, and only if there are multiple lines, I suffix each one with a new line when I concatenate them. This way a single-line comment becomes a simple string (w/o a final newline) but a multi-line comment preserves the indentation structure and the final newline in each line.
strum_tests/tests/enum_message.rs
Outdated
Bird, | ||
/// I'm disabled. |
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.
May as well make the comment overly explicit since it's just a test case.
/// get_documentation() will return None because #[strum(disabled)] is present
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.
Done.
I forgot to hit submit review :( sorry about that |
Did a pass (trying) to address the review issues. |
Ok, checks pass now. |
Released as part of |
Implement #203.