Skip to content
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

Merged
merged 4 commits into from Feb 21, 2022

Conversation

orenbenkiki
Copy link
Contributor

Implement #203.

@Peternator7
Copy link
Owner

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.

@orenbenkiki
Copy link
Contributor Author

What are the minor tweaks you'd like to see?

strum_macros/src/helpers/metadata.rs Outdated Show resolved Hide resolved
let params = params.clone();
// Push the documentation.
documentation_arms
.push(quote! { &#name::#ident #params => ::core::option::Option::Some(concat!(#( #documentation ),*).trim()) });
Copy link
Owner

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.

Copy link
Contributor Author

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 Show resolved Hide resolved
Bird,
/// I'm disabled.
Copy link
Owner

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

strum_macros/Cargo.toml Show resolved Hide resolved
@Peternator7
Copy link
Owner

I forgot to hit submit review :( sorry about that

@orenbenkiki
Copy link
Contributor Author

Did a pass (trying) to address the review issues.

@orenbenkiki
Copy link
Contributor Author

Ok, checks pass now.

@Peternator7 Peternator7 merged commit e558e91 into Peternator7:master Feb 21, 2022
@Peternator7
Copy link
Owner

Released as part of 0.24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants