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

docs: adds docstrings for some properties of InvokableSlashCommand and SubCommand and document Option's attributes #1112

Merged
merged 25 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c7f57ca
test crowdin workflows
Snipy7374 Feb 6, 2023
85d9279
Update crowdin.yml
Snipy7374 Feb 6, 2023
398cb5f
Merge branch 'DisnakeDev:master' into master
Snipy7374 Feb 20, 2023
56c184b
Merge branch 'DisnakeDev:master' into master
Snipy7374 Feb 24, 2023
9b2e760
Merge branch 'DisnakeDev:master' into master
Snipy7374 May 10, 2023
7888ed7
Merge branch 'DisnakeDev:master' into master
Snipy7374 Jun 22, 2023
e64a306
Merge branch 'DisnakeDev:master' into master
Snipy7374 Jun 23, 2023
9ca85ac
Merge branch 'DisnakeDev:master' into master
Snipy7374 Sep 24, 2023
85af871
discard crowndin shit
Snipy7374 Sep 24, 2023
fe76ff6
Merge branch 'master' of https://github.com/DisnakeDev/disnake
Snipy7374 Sep 24, 2023
f5f991c
Merge branch 'master' of github.com:Snipy7374/disnake
Snipy7374 Sep 24, 2023
0f6bb2e
add docs for some InvokableSlashCommand and SubCommand properties
Snipy7374 Sep 24, 2023
9124dcc
unfuck conf
Snipy7374 Sep 24, 2023
ab12485
fix SubCommand docstring
Snipy7374 Sep 24, 2023
0bd92dd
add changelog entry
Snipy7374 Sep 24, 2023
9d2bd53
document Option and update docstrings
Snipy7374 Oct 11, 2023
50622f3
Merge branch 'master' into docs_fix
Snipy7374 Oct 11, 2023
9a88ea4
Update disnake/ext/commands/slash_core.py
Snipy7374 Oct 13, 2023
6bb8c83
Update disnake/ext/commands/slash_core.py
Snipy7374 Oct 13, 2023
b52b538
fix Option attributes docstrings
Snipy7374 Oct 13, 2023
a6608fc
Merge branch 'master' into docs_fix
Snipy7374 Oct 13, 2023
2b31a84
add parameters to Option
Snipy7374 Nov 12, 2023
a7879d5
Merge branch 'master' into docs_fix
Snipy7374 Nov 12, 2023
9157a0a
fix(docs): fix broken references to core
shiftinv Nov 22, 2023
4e16e3e
Merge branch 'master' into docs_fix
shiftinv Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/1112.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document the :class:`.Option` attributes, the ``description`` and ``options`` properties for :class:`.ext.commands.InvokableSlashCommand` and the ``description`` and ``body`` properties for :class:`.ext.commands.SubCommand`.
34 changes: 34 additions & 0 deletions disnake/app_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,40 @@ class Option:

.. versionadded:: 2.6

max_length: :class:`int`
The maximum length for this option if this is a string option.

.. versionadded:: 2.6

Attributes
----------
name: :class:`str`
The option's name.
description: :class:`str`
The option's description.
type: :class:`OptionType`
The option type, e.g. :class:`OptionType.user`.
required: :class:`bool`
Whether this option is required.
choices: List[:class:`OptionChoice`]
The list of option choices.
options: List[:class:`Option`]
The list of sub options. Normally you don't have to specify it directly,
instead consider using ``@main_cmd.sub_command`` or ``@main_cmd.sub_command_group`` decorators.
channel_types: List[:class:`ChannelType`]
The list of channel types that your option supports, if the type is :class:`OptionType.channel`.
By default, it supports all channel types.
autocomplete: :class:`bool`
Whether this option can be autocompleted.
min_value: Union[:class:`int`, :class:`float`]
The minimum value permitted.
max_value: Union[:class:`int`, :class:`float`]
The maximum value permitted.
min_length: :class:`int`
The minimum length for this option if this is a string option.

.. versionadded:: 2.6

max_length: :class:`int`
The maximum length for this option if this is a string option.

Expand Down
4 changes: 4 additions & 0 deletions disnake/ext/commands/slash_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,12 @@ def parents(

@property
def description(self) -> str:
""":class:`str`: The slash sub command's description. Shorthand for :attr:`self.body.description <.Option.description>`."""
return self.body.description

@property
def body(self) -> Option:
""":class:`.Option`: The API representation for this slash sub command. Shorthand for :attr:`.SubCommand.option`"""
return self.option

async def _call_autocompleter(
Expand Down Expand Up @@ -508,10 +510,12 @@ def _ensure_assignment_on_copy(self, other: SlashCommandT) -> SlashCommandT:

@property
def description(self) -> str:
""":class:`str`: The slash command's description. Shorthand for :attr:`self.body.description <.SlashCommand.description>`."""
return self.body.description

@property
def options(self) -> List[Option]:
"""List[:class:`.Option`]: The list of options the slash command has. Shorthand for :attr:`self.body.options <.SlashCommand.options>`."""
return self.body.options

def sub_command(
Expand Down
2 changes: 1 addition & 1 deletion docs/api/app_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Option

.. attributetable:: Option

.. autoclass:: Option()
.. autoclass:: Option
:members:

OptionChoice
Expand Down