Conversation
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| # basically the same function but changed: |
There was a problem hiding this comment.
Not essential, but these comments could be docstrings
… names for the command wrappers)
lemonsaurus
left a comment
There was a problem hiding this comment.
All in all this is excellent work. The output looks phenomenal.
| # basically the same function but changed: | ||
| # - to make the helptext appear as a comment | ||
| # - to change the indentation to the PEP8 standard: 4 spaces | ||
| def _add_subcommands_to_page(self, max_width, commands): |
| def _add_subcommands_to_page(self, max_width, commands): | ||
| for name, command in commands: | ||
| if name in command.aliases: | ||
| # skip aliases |
There was a problem hiding this comment.
this is probably self explanatory.
| # """ | ||
| # await do_<command>(ctx, <args>) | ||
|
|
||
| # strip the command of bot. and () |
There was a problem hiding this comment.
this block (from here and until the return) generally feels too dense. PEP8 allows blank lines used sparingly to split code into logical sections, and this can be a real gift for good readability. personally I try to write comments that encapsulate the actions of at least 3-4 lines of code and then put blank lines before the comments.
I also try to make sure similar things are grouped together, and that similar actions are handled consistently. the comments should also apply the same tense (don't mix present tense and past tense). applying that philosophy to this section, I'd do something like this;
# strip the command of bot. and ()
stripped_command = self.command.name.replace(HELP_PREFIX, "").replace("()", "")
# get the args using the handy inspect module
argspec = getfullargspec(self.command.callback)
arguments = formatargspec(*argspec)
args_no_type_hints = ", ".join(argspec[0])
# remove self from the args
arguments = arguments.replace("self, ", "")
args_no_type_hints = args_no_type_hints.replace("self, ", "")
# prepare the different sections of the help output, and add them to the paginator
definition = f"async def {stripped_command}{arguments}:"
docstring = f" \"\"\"\n {self.command.help}\n \"\"\""
invocation = f" await do_{stripped_command}({args_no_type_hints})"
self._paginator.add_line(definition)
self._paginator.add_line(docstring)
self._paginator.add_line(invocation)
return self._paginator.pages| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def _add_subcommands_to_page(self, max_width, commands): |
| @@ -0,0 +1,102 @@ | |||
| # coding=utf-8 | |||
|
|
|||
There was a problem hiding this comment.
this blank line is, I believe, against the law
Add tag image support. Closes #7 See merge request python-discord/projects/bot!18
Added new HelpFormatter, for a more python-y looking help command.
Features:
Help code block formatted as python
Cogs appear as classes
Command helptext shows as comments
Ending note for help command shows as comments
Getting help for an individual cog still works
Getting help on a specific commands shows a mock definition of said command with helptext as it's docstring, and its arguments shown as the arguments to the function with added type hinting.