A docstring parser for hikari-crescent.
Project description
crescent-ext-docstrings
A docstring parser for hikari-crescent.
Installation
pip install crescent-ext-docstrings
Usage
This extension works for both class commands and function commands.
import crescent
from crescent.ext import docstrings
bot = crescent.Bot("...")
@bot.include
@docstrings.parse_doc
@crescent.command
async def example(ctx: crescent.Context, a: str, b: str) -> None:
"""
This is the command's description.
:param a:
This is the first param's description.
:param b:
This is the first param's description.
"""
await ctx.respond(f"{a=},{b=}")
@bot.include
@docstrings.parse_doc
@crescent.command(name="class_example")
class ClassExample:
"""
Other doc styles are supported. This is google doc style.
Args:
a: This is the first param's description.
b: This is the first param's description.
"""
a = crescent.option(str)
b = crescent.option(str)
async def callback(self, ctx: crescent.Context) -> None:
await ctx.respond(f"{self.a=},{self.b=}")
bot.run()
Doc Styles
Since this library relies on docstring-parser, the styles Rest, Google, Numpy, and Epydoc are supported. If no style is specified, the style will be inferred.
import docstrings
@bot.include
@docstrings.parse_doc(style=docstrings.Style.REST)
@crescent.command
async def example(ctx: crescent.Command, a: str) -> None:
"""
Rest style description.
:param a:
The parameter.
"""
...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file crescent_ext_docstrings-0.2.2.tar.gz
.
File metadata
- Download URL: crescent_ext_docstrings-0.2.2.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76ba0723fd89d3abd3d4205d364db21858080aee687a504476fe35c3cbf8ca4b |
|
MD5 | 8390b883696230d7e2911b6c19b8dc11 |
|
BLAKE2b-256 | 4379fcb552fd599043b979ece8b8f1573bcc99493be4dc75d14a6254237f5517 |
File details
Details for the file crescent_ext_docstrings-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: crescent_ext_docstrings-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd79873a392727c973a708eaca51b6883321dcc9b09c26b799e4ff2c30dc218 |
|
MD5 | 7c1443d3b31e03cc0e5d1908d3aa5e1a |
|
BLAKE2b-256 | 567226f971201764c5c482fef1e78189b0e65547b7366b601c2c8921420cc76d |