-
Notifications
You must be signed in to change notification settings - Fork 202
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
base: master
Are you sure you want to change the base?
Help format #427
Conversation
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() |
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.
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.
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.
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.
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.
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? 👀
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.)