Skip to content

📝 Improve docstring coverage across cogs #124

@anthropic-code-agent

Description

@anthropic-code-agent

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

  1. Better Help Commands: Red-bot uses docstrings to generate [p]help output
  2. Developer Documentation: Makes code easier to understand and maintain
  3. IDE Support: Enables better autocomplete and inline help
  4. API Documentation: Tools like Sphinx can generate docs automatically
  5. 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

  1. Audit all cogs for missing docstrings
  2. Add class-level docstrings to all cogs
  3. Add parameter documentation to public methods
  4. Add docstrings to complex helper functions
  5. Fix any incorrectly formatted docstrings (single quotes, etc.)

Testing

After improvements:

  1. Check [p]help output for all commands
  2. Verify docstrings are accessible via help(MyCog)
  3. Run documentation generators (if applicable)

Related

This is part of a comprehensive code review. See other issues for additional improvements.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions