aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2021-05-21 19:53:33 +0200
committerGravatar Numerlor <[email protected]>2021-05-21 20:11:59 +0200
commit734e4ef5594b4d4336477f63ca2afd64684f54b6 (patch)
tree69ae703d8fe0abc443f024b11c54d187382b8db5
parentMerge pull request #1593 from python-discord/flake-8-isn't-a-task (diff)
Prefer using the package name as a prefix when handling symbol conflicts
When renaming, having label.symbol etc. in the list of the renamed symbol in the embed doesn't really provide much context on what that symbol may be to the user. Prioritizing the package name instead should makes it clearer that it's from an another package. Conflicts within a package are still resolved using the previous logic
-rw-r--r--bot/exts/info/doc/_cog.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py
index 2a8016fb8..ad244db4e 100644
--- a/bot/exts/info/doc/_cog.py
+++ b/bot/exts/info/doc/_cog.py
@@ -181,22 +181,22 @@ class DocCog(commands.Cog):
else:
return new_name
- # Certain groups are added as prefixes to disambiguate the symbols.
- if group_name in FORCE_PREFIX_GROUPS:
- return rename(group_name)
-
- # The existing symbol with which the current symbol conflicts should have a group prefix.
- # It currently doesn't have the group prefix because it's only added once there's a conflict.
- elif item.group in FORCE_PREFIX_GROUPS:
- return rename(item.group, rename_extant=True)
+ # When there's a conflict, and the package names of the items differ, use the package name as a prefix.
+ if package_name != item.package:
+ if package_name in PRIORITY_PACKAGES:
+ return rename(item.package, rename_extant=True)
+ else:
+ return rename(package_name)
- elif package_name in PRIORITY_PACKAGES:
- return rename(item.package, rename_extant=True)
+ # If the symbol's group is a non-priority group from FORCE_PREFIX_GROUPS,
+ # add it as a prefix to disambiguate the symbols.
+ elif group_name in FORCE_PREFIX_GROUPS:
+ return rename(item.group)
- # If we can't specially handle the symbol through its group or package,
- # fall back to prepending its package name to the front.
+ # If the above conditions didn't pass, either the existing symbol has its group in FORCE_PREFIX_GROUPS,
+ # or deciding which item to rename would be arbitrary, so we rename the existing symbol.
else:
- return rename(package_name)
+ return rename(item.group, rename_extant=True)
async def refresh_inventories(self) -> None:
"""Refresh internal documentation inventories."""