aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-07-26 15:51:34 +0200
committerGravatar Numerlor <[email protected]>2020-07-26 15:51:34 +0200
commit5290fcf0fff23e4979746c51b77be9a51fe82ae7 (patch)
tree9c561d1d1adaf23899dcffd5d469c5811daeefcd
parentRename description functions to be more general (diff)
Properly parse labels add fallback for non dt tags
Labels point to tags that aren't in description lists, like modules or doc symbols which we already handle. If by chance we get a symbol that we don't have in the group for general parsing and which isn't a dt tag, log it and don't attempt to parse signature and use general description parsing instead of parsing a dd tag.
-rw-r--r--bot/cogs/doc/parsing.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/bot/cogs/doc/parsing.py b/bot/cogs/doc/parsing.py
index 96bb1dfb4..1271953d4 100644
--- a/bot/cogs/doc/parsing.py
+++ b/bot/cogs/doc/parsing.py
@@ -206,12 +206,20 @@ async def get_symbol_markdown(http_session: ClientSession, symbol_data: "DocItem
soup = await _get_soup_from_url(http_session, request_url)
symbol_heading = soup.find(id=symbol_id)
-
- # Handle doc symbols as modules, because they either link to the page of a module,
- # or don't contain any useful info to be parsed.
signature = None
- if symbol_data.group in {"module", "doc"}:
- log.trace("Symbol is a module or doc, parsing as module.")
+ # Modules, doc pages and labels don't point to description list tags but to tags like divs,
+ # no special parsing can be done so we only try to include what's under them.
+ if symbol_data.group in {"module", "doc", "label"}:
+ log.trace("Symbol is a module, doc or a label; using general description parsing.")
+ description = _get_general_description(symbol_heading)
+
+ elif symbol_heading.name != "dt":
+ # Use the general parsing for symbols that aren't modules, docs or labels and aren't dt tags,
+ # log info the tag can be looked at.
+ log.info(
+ f"Symbol heading at url {symbol_data.url} was not a dt tag or from known groups that lack it,"
+ f"handling as general description."
+ )
description = _get_general_description(symbol_heading)
elif symbol_data.group in _NO_SIGNATURE_GROUPS: