Description
Several cogs have missing or incomplete docstrings, making it harder for developers to understand the code and for users to see help documentation.
Issues Found
1. misc/misc.py - Incorrect docstring format
Current:
class Misc(commands.Cog):
"Misc things for your server" # ❌ Single-quoted string, not a docstring
Should be:
class Misc(commands.Cog):
"""Misc things for your server."""
Problem: Single-quoted strings are not recognized as docstrings by Python's __doc__ attribute and documentation tools.
2. quotesdb/quotedb.py - Missing class docstring
Current:
class QuotesDB(commands.Cog):
def __init__(self, bot):
# No class docstring
Should add:
class QuotesDB(commands.Cog):
"""Store and retrieve user-generated quotes with triggers.
Users can add quotes with triggers and recall them later.
Each quote is assigned a unique ID for management.
"""
3. empty_voices/api.py - Missing parameter documentation
Current:
async def cleanup_temp_channels_config(self, channel):
"""Cleanup temp_channels config if a channel is deleted."""
Should add parameter docs:
async def cleanup_temp_channels_config(self, channel):
"""Cleanup temp_channels config if a channel is deleted.
Parameters
----------
channel : discord.VoiceChannel
The voice channel that was deleted
"""
4. Multiple helper functions lack docstrings
Many private methods (starting with _) lack docstrings:
party/party.py: Multiple modal and view classes
secret_santa/secret_santa.py: Helper methods
albion_ava/ava.py: Graph generation functions
Benefits of Good Docstrings
- Better Help Commands: Red-bot uses docstrings to generate
[p]help output
- Developer Documentation: Makes code easier to understand and maintain
- IDE Support: Enables better autocomplete and inline help
- API Documentation: Tools like Sphinx can generate docs automatically
- Code Quality: Forces developers to think about purpose and parameters
Recommended Format
For Red-bot cogs, follow this format:
@commands.command()
async def mycommand(self, ctx, arg1: str, arg2: int = 5):
"""Brief description of what the command does.
More detailed explanation if needed. This appears in help text.
Parameters
----------
arg1 : str
Description of arg1
arg2 : int, optional
Description of arg2, default is 5
Examples
--------
[p]mycommand "hello" 10
[p]mycommand "world"
"""
For classes:
class MyCog(commands.Cog):
"""Brief description of the cog.
Longer description of what this cog does and its purpose.
Lists key features and usage notes.
"""
For methods:
async def helper_method(self, param1, param2):
"""Brief description of the method.
Parameters
----------
param1 : type
Description
param2 : type
Description
Returns
-------
type
Description of return value
Raises
------
ExceptionType
When this exception is raised
"""
Priority
LOW - Doesn't affect functionality but improves code quality and maintainability.
Implementation Plan
- Audit all cogs for missing docstrings
- Add class-level docstrings to all cogs
- Add parameter documentation to public methods
- Add docstrings to complex helper functions
- Fix any incorrectly formatted docstrings (single quotes, etc.)
Testing
After improvements:
- Check
[p]help output for all commands
- Verify docstrings are accessible via
help(MyCog)
- Run documentation generators (if applicable)
Related
This is part of a comprehensive code review. See other issues for additional improvements.
Description
Several cogs have missing or incomplete docstrings, making it harder for developers to understand the code and for users to see help documentation.
Issues Found
1.
misc/misc.py- Incorrect docstring formatCurrent:
Should be:
Problem: Single-quoted strings are not recognized as docstrings by Python's
__doc__attribute and documentation tools.2.
quotesdb/quotedb.py- Missing class docstringCurrent:
Should add:
3.
empty_voices/api.py- Missing parameter documentationCurrent:
Should add parameter docs:
4. Multiple helper functions lack docstrings
Many private methods (starting with
_) lack docstrings:party/party.py: Multiple modal and view classessecret_santa/secret_santa.py: Helper methodsalbion_ava/ava.py: Graph generation functionsBenefits of Good Docstrings
[p]helpoutputRecommended Format
For Red-bot cogs, follow this format:
For classes:
For methods:
Priority
LOW - Doesn't affect functionality but improves code quality and maintainability.
Implementation Plan
Testing
After improvements:
[p]helpoutput for all commandshelp(MyCog)Related
This is part of a comprehensive code review. See other issues for additional improvements.