Skip to content

Commit

Permalink
PR #27 Docs: standardize style across project
Browse files Browse the repository at this point in the history
  • Loading branch information
kwzrd authored Sep 17, 2020
2 parents 5456347 + 8c0aa71 commit 0d40036
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
9 changes: 6 additions & 3 deletions ryan/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Ryan(commands.Bot):
database: Database

def __init__(self, *args, **kwargs) -> None:
"""Prepare an aiohttp session for the bot to use.
"""
Prepare an aiohttp session for the bot to use.
All args and kwargs propagate to super.
"""
Expand All @@ -26,15 +27,17 @@ def __init__(self, *args, **kwargs) -> None:
)

def add_cog(self, cog: commands.Cog) -> None:
"""Delegate to super, log successful loads.
"""
Delegate to super, log successful loads.
This reduces having to log in cog module setups.
"""
super().add_cog(cog)
log.info(f"Cog loaded: {cog.qualified_name}")

async def start(self, *args, **kwargs) -> None:
"""Prepare Bot subclass.
"""
Prepare Bot subclass.
We establish a connection to the database here from an async context,
then delegate to the base class.
Expand Down
9 changes: 6 additions & 3 deletions ryan/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@


class Database:
"""Provides a simple API for the internal `_connection` to an SQLIte database.
"""
Provides a simple API for the internal `_connection` to an SQLIte database.
Ideally the database is only interfaced with through an instance of this class.
"""
Expand All @@ -31,7 +32,8 @@ def size(self) -> int:
return self.DB_FILE.stat().st_size

async def open(self) -> Database:
"""Open a connection to the database from an asynchronous context.
"""
Open a connection to the database from an asynchronous context.
Creates necessary tables if they don't exist.
Expand All @@ -53,7 +55,8 @@ async def open(self) -> Database:
return self

async def get_nicknames(self) -> List[str]:
"""Retrieve a list of all nicknames.
"""
Retrieve a list of all nicknames.
Gives an empty list should no nicknames be available.
"""
Expand Down
9 changes: 6 additions & 3 deletions ryan/exts/gallonmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def is_gallonmate(user: discord.User) -> bool:


async def seconds_until_midnight() -> float:
"""Give the amount of seconds needed to wait until the next-up midnight.
"""
Give the amount of seconds needed to wait until the next-up midnight.
The exact `midnight` moment is actually delayed to 5 seconds after, in order
to avoid potential race conditions due to imprecise sleep.
Expand All @@ -35,7 +36,8 @@ async def seconds_until_midnight() -> float:


async def get_help(group: commands.Group, failed_cmd: bool) -> discord.Embed:
"""Provide an embed with commands of `group`.
"""
Provide an embed with commands of `group`.
If `failed_cmd` is True, the embed is coloured orange. Green otherwise.
"""
Expand Down Expand Up @@ -102,7 +104,8 @@ async def switch_daemon_func(self) -> None:
await ann_channel.send(embed=msg_success(msg))

async def switch_routine(self) -> Tuple[str, str]:
"""Routine to attempt to switch Gallonmate nickname.
"""
Routine to attempt to switch Gallonmate nickname.
If the method fails at any point, it will raise SwitchException with an informative
message the can be displayed to the user.
Expand Down
9 changes: 6 additions & 3 deletions ryan/exts/seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@


def decorate_name(discord_name: str, season_name: str) -> str:
"""Decorate a given string with emoji for current season.
"""
Decorate a given string with emoji for current season.
The used emoji are drawn randomly from the season given by `season_name`.
Strips all other emoji from `discord_name` before decorating.
Expand All @@ -71,7 +72,8 @@ def decorate_name(discord_name: str, season_name: str) -> str:


class Seasons(commands.Cog):
"""Decorates the server for various seasons.
"""
Decorates the server for various seasons.
The guild name, channel names and member names will be decorated with
emoji that are pre-defined for each season.
Expand All @@ -97,7 +99,8 @@ def __init__(self, bot: Ryan) -> None:

@commands.command()
async def season(self, ctx: commands.Context, *, season_name: str = None) -> None:
"""Attempt to decorate the server.
"""
Attempt to decorate the server.
Many of the decorations may fail due to missing permissions. The bot handles
this and returns an embed containing a report of how many decorations have
Expand Down

0 comments on commit 0d40036

Please sign in to comment.