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

Allow spanning description content across many lines like Markdown #1254

Merged
merged 1 commit into from
Mar 8, 2021

Conversation

arqunis
Copy link
Member

@arqunis arqunis commented Mar 7, 2021

Description

This adds support for splitting content of command and group descriptions across multiple lines for readability like in the Markdown format. To be specific, when several #[description] attributes are provided to the #[command] and #[group] macros, their content is stitched together to a single string according to the following new rules:

  • If the content of a #[description] consists of just whitespace or is empty, a plain newline ('\n') is appended to the string.
  • If the content isn't just whitespace nor empty, a space (' ') and the content are appended to the string.

Type of Change

This enhances the usage of command_attr's macros, a part of the framework.

How Has This Been Tested?

This has been tested by checking the output of cargo expand for the values of descriptions for commands and groups, where it has been confirmed that the stitching works as expected.

@arqunis arqunis added enhancement An improvement to Serenity. framework Related to the `framework` and `framework::standard` modules and/or the `command_attr` crate command_attr Related to the `command_attr` crate. labels Mar 7, 2021
@arqunis arqunis force-pushed the markdown_like_line_spanning branch from 8fc9fed to b0111cb Compare March 8, 2021 17:41
@arqunis arqunis merged commit dbc40cb into serenity-rs:current Mar 8, 2021
@arqunis arqunis deleted the markdown_like_line_spanning branch March 8, 2021 20:15
arqunis added a commit that referenced this pull request Mar 30, 2021
This adds a way for joining lines in the documentation comments of the `#[command]` and `#[group]` macros, while simultaneously reverting the Markdown-like behaviour of joining lines introduced in #1254. With these changes, the macros try to retain all newlines, unless the user explicitly opts-out by ending a line with `\$`, in which case the line will end with a space and combine the next line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command_attr Related to the `command_attr` crate. enhancement An improvement to Serenity. framework Related to the `framework` and `framework::standard` modules and/or the `command_attr` crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant