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

Help format #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Help format #427

wants to merge 1 commit into from

Conversation

algmyr
Copy link
Collaborator

@algmyr algmyr commented Jan 5, 2021

Remove single newlines in help strings (that are generated from the docstrings). Newlines prefixed with \\ remain, double newlines (paragraphs) remain. (May or may not behave akin to LaTeX now.)

@algmyr algmyr requested a review from meooow25 January 5, 2021 19:10
Comment on lines +142 to +159
if command.description:
self.paginator.add_line(command.description, empty=True)

signature = self.get_command_signature(command)
if command.aliases:
self.paginator.add_line(signature)
self.add_aliases_formatting(command.aliases)
else:
self.paginator.add_line(signature, empty=True)

if command.help:
try:
new_help = TLEHelpCommand._reformat(command.help)
self.paginator.add_line(new_help, empty=True)
except RuntimeError:
for line in command.help.splitlines():
self.paginator.add_line(line)
self.paginator.add_line()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably a bit fragile to depend on the internal implementation, don't you think? 🤔
What if we instead have a decorator on the methods that update the docstring? Or if we don't want to be that granular, we could update command.help for each command in the bot after we have added the cogs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it that fragile? We could fork the thing if that makes you happier. This just felt like the minimal effort route, and I doubt the api of the DefaultHelpCommand would change drastically. What internal implementation do I actually depend on?

What if we instead have a decorator on the methods that update the docstring?

What do you mean exactly?

Or if we don't want to be that granular, we could update command.help for each command in the bot after we have added the cogs.

That feels hackier than what I did here tbh.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What internal implementation do I actually depend on?

That was a bad choice of words, I meant that a piece of logic is copied from the default impl. Also the API will probably not change so this may be fine 🤷

What if we instead have a decorator on the methods that update the docstring?

What do you mean exactly?

def reformat_help(func):
    func.__doc__ = _reformat(func.__doc__)
    return func

Or if we don't want to be that granular, we could update command.help for each command in the bot after we have added the cogs.

That feels hackier than what I did here tbh.

Why though :waturr:
This is just the line new_help = TLEHelpCommand._reformat(command.help) from the PR.

for command in bot.walk_commands():
    command.help = _reformat(command.help)

I probably like the last option the most. What do you think? 👀

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

Successfully merging this pull request may close these issues.

2 participants