aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2019-10-21 22:10:45 +0200
committerGravatar Numerlor <[email protected]>2019-10-21 22:10:45 +0200
commit55b276a1f7e56a950e215bd8289b7f946b2f180e (patch)
tree001a3cf2303457ef7dd082aa403ef65257253569
parentDon't include a signature and only get first paragraphs when scraping when sy... (diff)
Allow embeds to not include signatures in case the symbol is a module
-rw-r--r--bot/cogs/doc.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py
index a13552ac0..0c370f665 100644
--- a/bot/cogs/doc.py
+++ b/bot/cogs/doc.py
@@ -288,21 +288,24 @@ class Doc(commands.Cog):
description = WHITESPACE_AFTER_NEWLINES_RE.sub('', description)
- if not signature:
+ if signature is None:
+ # If symbol is a module, don't show signature.
+ embed_description = description
+
+ elif not signature:
# It's some "meta-page", for example:
# https://docs.djangoproject.com/en/dev/ref/views/#module-django.views
- embed = discord.Embed(
- title=f'`{symbol}`',
- url=permalink,
- description="This appears to be a generic page not tied to a specific symbol."
- )
+ embed_description = "This appears to be a generic page not tied to a specific symbol."
+
else:
signature = textwrap.shorten(signature, 500)
- embed = discord.Embed(
- title=f'`{symbol}`',
- url=permalink,
- description=f"```py\n{signature}```{description}"
- )
+ embed_description = f"```py\n{signature}```{description}"
+
+ embed = discord.Embed(
+ title=f'`{symbol}`',
+ url=permalink,
+ description=embed_description
+ )
# show all symbols with the same name that were renamed in the footer
embed.set_footer(text=", ".join(renamed for renamed in self.renamed_symbols - {symbol}
if renamed.endswith(f".{symbol}"))