Skip to content

Commit 8487cf2

Browse files
authored
Merge pull request #1 from cburgard/main
add doxygen documentation
2 parents 1111200 + 1d2ba96 commit 8487cf2

File tree

8 files changed

+2699
-36
lines changed

8 files changed

+2699
-36
lines changed

Doxyfile

Lines changed: 2618 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ https://github.com/Info-Bonn/poll-bot
3434
I collected the most useful and generic functions to save me some time when starting the next bot-project.
3535

3636
### dependencies
37-
This project is based on `discord.py V1.x` minimum required: V1.5.1
37+
This project is based on `discord.py V1.x` minimum required: V1.5.1
38+
39+
### documentation
40+
In order to render this documentation, just call `doxygen`

src/cogs/help.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
import utils as utl
55
from environment import OWNER_NAME, OWNER_ID, VERSION, PREFIX
66

7-
"""
8-
This custom help command is a replacement for the default one on any Discord Bot written in discord.py!
9-
However, you must put "bot.remove_command('help')" in your bot, and the command must be in a cog for it to work.
10-
11-
Original concept by Jared Newsom (AKA Jared M.F.)
12-
[link no longer available] https://gist.github.com/StudioMFTechnologies/ad41bfd32b2379ccffe90b0e34128b8b
13-
Rewritten and optimized by https://github.com/nonchris
14-
https://gist.github.com/nonchris/1c7060a14a9d94e7929aa2ef14c41bc2
15-
16-
This version relies more on the structure around this module than the gist does, which is more 'stand alone'
17-
"""
7+
### @package help
8+
#
9+
# This custom help command is a replacement for the default one on any Discord Bot written in discord.py!
10+
# However, you must put "bot.remove_command('help')" in your bot, and the command must be in a cog for it to work.
11+
#
12+
# Original concept by [Jared Newsom (AKA Jared M.F.)](https://gist.github.com/StudioMFTechnologies/ad41bfd32b2379ccffe90b0e34128b8b)
13+
# Rewritten and optimized by [nonchris](https://github.com/nonchris)
14+
#
15+
# This version relies more on the structure around this module than the gist does, which is more 'stand alone'
1816

1917

2018
class Help(commands.Cog):
@@ -23,12 +21,22 @@ class Help(commands.Cog):
2321
"""
2422

2523
def __init__(self, bot):
24+
"""!
25+
Constructor
26+
27+
@param bot The bot instance to be used.
28+
"""
2629
self.bot = bot
2730

2831
@commands.command(aliases=['h', 'hilfe'])
2932
# @commands.bot_has_permissions(add_reactions=True,embed_links=True)
3033
async def help(self, ctx, *params):
31-
"""Shows all modules of that bot"""
34+
"""!
35+
Shows all modules of that bot
36+
37+
@param ctx Context of the message.
38+
@param params further arguments
39+
"""
3240

3341
# checks if cog parameter was given
3442
# if not: sending all modules and commands not associated with a cog
@@ -121,4 +129,9 @@ async def help(self, ctx, *params):
121129

122130

123131
def setup(bot):
132+
"""!
133+
Setup a bot.
134+
135+
@param bot The bot to setup.
136+
"""
124137
bot.add_cog(Help(bot))

src/cogs/misc.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import utils as ut
55

66

7+
### @package misc
8+
#
9+
# Collection of miscellaneus helpers.
10+
#
11+
712
class Misc(commands.Cog):
813
"""
914
Various useful Commands for everyone
@@ -14,6 +19,11 @@ def __init__(self, bot):
1419

1520
@commands.command(name='ping', help="Check if Bot available")
1621
async def ping(self, ctx):
22+
"""!
23+
ping to check if the bot is available
24+
25+
@param ctx Context of the message
26+
"""
1727
print(f"ping: {round(self.bot.latency * 1000)}")
1828

1929
await ctx.send(
@@ -24,4 +34,4 @@ async def ping(self, ctx):
2434

2535

2636
def setup(bot):
27-
bot.add_cog(Misc(bot))
37+
bot.add_cog(Misc(bot))

src/environment.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import os
22
import logging
33

4+
### @package environment
5+
#
6+
# Interacitons with the environment variables.
7+
#
48

59
def load_env(key: str, default: str) -> str:
6-
"""
10+
"""!
711
os.getenv() wrapper that handles the case of None-types for not-set env-variables\n
812
9-
:param key: name of env variable to load
10-
:param default: default value if variable couldn't be loaded
11-
:return: value of env variable or default value
13+
@param key: name of env variable to load
14+
@param default: default value if variable couldn't be loaded
15+
@return value of env variable or default value
1216
"""
1317
value = os.getenv(key)
1418
if value:

src/log_setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import os
22
import logging
33

4+
### @package log_setup
5+
#
6+
# Setup of logging
7+
#
8+
49
# path for databases or config files
510
if not os.path.exists('data/'):
611
os.mkdir('data/')

src/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/env python
12
import os
23

34
import discord
@@ -20,6 +21,9 @@
2021
# login message
2122
@bot.event
2223
async def on_ready():
24+
"""!
25+
function called when the bot is ready. emits the '[Bot] has connected' message
26+
"""
2327
print(f'{bot.user.name} has connected')
2428

2529
logger.info(f"Bot has connected, active on {len(bot.guilds)} guilds")

src/utils.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import discord
22
from discord.errors import Forbidden
33

4-
"""
5-
The color presets, send_message() and make_embed() functions are included in the discord-bot template by nonchris
6-
https://github.com/nonchris/discord-bot
7-
"""
4+
### @package utils
5+
#
6+
# The color presets, send_message() and make_embed() functions are
7+
# included in the [discord-bot template by
8+
# nonchris](https://github.com/nonchris/discord-bot)
89

910

1011
# color scheme for embeds as rbg
1112
blue_light = discord.Color.from_rgb(20, 255, 255) # default color
1213
green = discord.Color.from_rgb(142, 250, 60) # success green
13-
yellow = discord.Color.from_rgb(245, 218, 17) # waring like 'hey, that's not cool'
14-
orange = discord.Color.from_rgb(245, 139, 17) # waring - rather critical like 'no more votes left'
14+
yellow = discord.Color.from_rgb(245, 218, 17) # warning like 'hey, that's not cool'
15+
orange = discord.Color.from_rgb(245, 139, 17) # warning - rather critical like 'no more votes left'
1516
red = discord.Color.from_rgb(255, 28, 25) # error red
1617

18+
### @package utils
19+
#
20+
# Utilities and helper functions
21+
#
1722

1823
async def send_embed(ctx, embed):
19-
"""
24+
"""!
2025
Handles the sending of embeds
21-
-> Takes context and embed to send
26+
@param ctx context to send to
27+
@param embed embed to send
28+
2229
- tries to send embed in channel
2330
- tries to send normal message when that fails
2431
- tries to send embed private with information abot missing permissions
@@ -35,18 +42,17 @@ async def send_embed(ctx, embed):
3542
f"May you inform the server team about this issue? :slight_smile:", embed=embed)
3643

3744

38-
# creating and returning an embed with keyword arguments
39-
# please note that name and value can't be empty - name and value contain a zero width non-joiner
4045
def make_embed(title="", color=blue_light, name="‌", value="‌", footer=None) -> discord.Embed:
41-
"""
46+
"""!
4247
Function to generate generate an embed in one function call
43-
44-
:param title: Headline of embed
45-
:param color: RGB Tuple (Red, Green, Blue)
46-
:param name: Of field (sub-headline)
47-
:param value: Text of field (actual text)
48-
:param footer: Text in footer
49-
:return: Embed ready to send
48+
please note that name and value can't be empty - name and value contain a zero width non-joiner
49+
50+
@param title Headline of embed
51+
@param color RGB Tuple (Red, Green, Blue)
52+
@param name: Of field (sub-headline)
53+
@param value: Text of field (actual text)
54+
@param footer: Text in footer
55+
@return Embed ready to send
5056
"""
5157
# make color object
5258
emb = discord.Embed(title=title, color=color)

0 commit comments

Comments
 (0)