[commands] Allow setting description of cogs
This commit is contained in:
parent
5bad633987
commit
4adbe03d7c
@ -70,6 +70,11 @@ class CogMeta(type):
|
|||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
The cog name. By default, it is the name of the class with no modification.
|
The cog name. By default, it is the name of the class with no modification.
|
||||||
|
description: :class:`str`
|
||||||
|
The cog description. By default, it is the cleaned docstring of the class.
|
||||||
|
|
||||||
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
command_attrs: :class:`dict`
|
command_attrs: :class:`dict`
|
||||||
A list of attributes to apply to every command inside this cog. The dictionary
|
A list of attributes to apply to every command inside this cog. The dictionary
|
||||||
is passed into the :class:`Command` options at ``__init__``.
|
is passed into the :class:`Command` options at ``__init__``.
|
||||||
@ -93,6 +98,11 @@ class CogMeta(type):
|
|||||||
attrs['__cog_name__'] = kwargs.pop('name', name)
|
attrs['__cog_name__'] = kwargs.pop('name', name)
|
||||||
attrs['__cog_settings__'] = command_attrs = kwargs.pop('command_attrs', {})
|
attrs['__cog_settings__'] = command_attrs = kwargs.pop('command_attrs', {})
|
||||||
|
|
||||||
|
description = kwargs.pop('description', None)
|
||||||
|
if description is None:
|
||||||
|
description = inspect.cleandoc(attrs.get('__doc__', ''))
|
||||||
|
attrs['__cog_description__'] = description
|
||||||
|
|
||||||
commands = {}
|
commands = {}
|
||||||
listeners = {}
|
listeners = {}
|
||||||
no_bot_cog = 'Commands or listeners must not start with cog_ or bot_ (in method {0.__name__}.{1})'
|
no_bot_cog = 'Commands or listeners must not start with cog_ or bot_ (in method {0.__name__}.{1})'
|
||||||
@ -209,11 +219,11 @@ class Cog(metaclass=CogMeta):
|
|||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
""":class:`str`: Returns the cog's description, typically the cleaned docstring."""
|
""":class:`str`: Returns the cog's description, typically the cleaned docstring."""
|
||||||
try:
|
return self.__cog_description__
|
||||||
return self.__cog_cleaned_doc__
|
|
||||||
except AttributeError:
|
@description.setter
|
||||||
self.__cog_cleaned_doc__ = cleaned = inspect.getdoc(self)
|
def description(self, description):
|
||||||
return cleaned
|
self.__cog_description__ = description
|
||||||
|
|
||||||
def walk_commands(self):
|
def walk_commands(self):
|
||||||
"""An iterator that recursively walks through this cog's commands and subcommands.
|
"""An iterator that recursively walks through this cog's commands and subcommands.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user