Skip to content

Commit

Permalink
Changed class documentation to fix sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanAkkerman committed Aug 28, 2023
1 parent b46bfa2 commit 81a91da
Show file tree
Hide file tree
Showing 27 changed files with 349 additions and 345 deletions.
31 changes: 29 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,50 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["sphinx.ext.napoleon", "sphinx.ext.viewcode", "sphinx.ext.autodoc"]
extensions = [
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.todo",
"sphinx_automodapi.automodapi",
"sphinx.ext.graphviz",
"sphinx.ext.napoleon",
"sphinx.ext.githubpages",
"sphinx_autodoc_typehints",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

autosummary_generate = True


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]

autodoc_mock_imports = ["torch", "transformers"]


def skip_member(app, what, name, obj, skip, options):
# Ignore all setup methods
if name == "setup":
return True
return skip


def setup(app):
app.connect("autodoc-skip-member", skip_member)


# Commands:
# set SPHINX_APIDOC_OPTIONS=members,show-inheritance
# sphinx-apidoc -o . ../src/

# make clean html
# make html

# https://github.com/unit8co/darts/blob/master/docs/source/conf.py
# https://unit8co.github.io/darts/index.html
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Welcome to FinTwit Bot's documentation!
:maxdepth: 2
:caption: Contents:

modules
Modules<modules>

Indices and tables
==================
Expand Down
5 changes: 5 additions & 0 deletions src/cogs/commands/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@


class Analyze(commands.Cog):
"""
This class is used to handle the analyze command.
You can enable / disable this command in the config, under ["COMMANDS"]["ANALYZE"].
"""

def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

Expand Down
7 changes: 0 additions & 7 deletions src/cogs/commands/earnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ class Earnings(commands.Cog):
"""
This class is used to handle the earnings command.
You can enable / disable this command in the config, under ["COMMANDS"]["EARNINGS"].
Methods
-------
earnings(ctx : commands.context.Context, stock : str) -> None:
This method is used to handle the earnings command.
earnings_error(ctx : commands.context.Context, error : Exception) -> None:
This method is used to handle the errors when using the `!earnings` command.
"""

def __init__(self, bot: commands.Bot):
Expand Down
4 changes: 4 additions & 0 deletions src/cogs/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@


class Help(commands.Cog):
"""
Custom help command.
"""

def __init__(self, bot):
self.bot = bot
self.cmd_dict = {}
Expand Down
25 changes: 9 additions & 16 deletions src/cogs/commands/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
class Portfolio(commands.Cog):
"""
This class is used to handle the portfolio command.
Methods
----------
portfolio(ctx : commands.context.Context, *input : tuple) -> None:
Adds or removes your portfolio to the database.
portfolio_error(ctx : commands.context.Context, *input : tuple) -> None:
Handles the errors when using the `!portfolio` command.
You can enable / disable this command in the config, under ["COMMANDS"]["PORTFOLIO"].
"""

# Create a slash command group
Expand All @@ -32,7 +26,6 @@ def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

def update_portfolio_db(self, new_db):

# Set the new portfolio so other functions can access it
util.vars.portfolio_db = new_db

Expand Down Expand Up @@ -89,8 +82,8 @@ async def add(
if exchange.lower() == "binance":
if len(input) != 3:
raise commands.BadArgument()
exchange = ccxt.binance({'apiKey': key, 'secret': secret})

exchange = ccxt.binance({"apiKey": key, "secret": secret})

new_data = pd.DataFrame(
{
Expand All @@ -103,9 +96,9 @@ async def add(
},
index=[0],
)

# Before adding the portfolio, check if it already exists

# Check if the API keys are valid
print(exchange.fetch_status())

Expand Down Expand Up @@ -146,7 +139,7 @@ async def remove(
(old_db["id"] == ctx.author.id) & (old_db["exchange"] == exchange)
].tolist()
else:
rows = old_db.index[old_db["id"] == ctx.author.id].tolist()
rows = old_db.index[old_db["id"] == ctx.author.id].tolist()

# Update database
self.update_portfolio_db(old_db.drop(rows))
Expand Down Expand Up @@ -179,7 +172,7 @@ async def show(

@add.error
async def add_error(self, ctx: commands.Context, error: Exception) -> None:
#print(traceback.format_exc())
# print(traceback.format_exc())
if isinstance(error, commands.BadArgument):
await ctx.respond(
f"The exchange you specified is currently not supported! \nSupported exchanges: Kucoin, Binance"
Expand All @@ -198,12 +191,12 @@ async def add_error(self, ctx: commands.Context, error: Exception) -> None:

@remove.error
async def remove_error(self, ctx: commands.Context, error: Exception) -> None:
#print(traceback.format_exc())
# print(traceback.format_exc())
await ctx.respond(f"An error has occurred. Please try again later.")

@show.error
async def show_error(self, ctx: commands.Context, error: Exception) -> None:
#print(traceback.format_exc())
# print(traceback.format_exc())
if isinstance(error, commands.PrivateMessageOnly):
await ctx.respond(
"Please only use the `/portfolio` command in private messages for security reasons."
Expand Down
7 changes: 0 additions & 7 deletions src/cogs/commands/sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ class Sentiment(commands.Cog):
"""
This class is used to handle the sentiment command.
You can enable / disable this command in the config, under ["COMMANDS"]["SENTIMENT"].
Methods
-------
sentiment(ctx : commands.context.Context, stock : str) -> None:
This method is used to handle the earnings command.
get_news(ticker : str) -> None:
This method is used to handle the errors when using the `!earnings` command.
"""

def __init__(self, bot: commands.Bot) -> None:
Expand Down
Loading

0 comments on commit 81a91da

Please sign in to comment.