diff options
author | 2021-05-21 20:04:15 +0200 | |
---|---|---|
committer | 2021-05-21 20:11:59 +0200 | |
commit | b6ccd0396a551e471ddfb80ec129e38e3ff88d01 (patch) | |
tree | b1abe802e2db56741aec20515edd52a5b9dfebff | |
parent | Prefer using the package name as a prefix when handling symbol conflicts (diff) |
Prioritize symbols depending on their group's pos in FORCE_PREFIX_GROUPS
When both symbols are in FORCE_PREFIX_GROUPS, instead of relying on which symbol
comes later and always renaming the latter one, the symbols with a lower
priority group are moved out of the way instead of forcing the new symbol to be
moved.
This will help make relevant symbols be more likely to come up when
searching the docs.
The constant was reordered by the priority of the groups to work with this
change
-rw-r--r-- | bot/exts/info/doc/_cog.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index ad244db4e..d969f6fd4 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -27,11 +27,11 @@ log = logging.getLogger(__name__) # symbols with a group contained here will get the group prefixed on duplicates FORCE_PREFIX_GROUPS = ( - "2to3fixer", - "token", + "term", "label", + "token", "pdbcommand", - "term", + "2to3fixer", ) NOT_FOUND_DELETE_DELAY = RedirectOutput.delete_delay # Delay to wait before trying to reach a rescheduled inventory again, in minutes @@ -191,7 +191,11 @@ class DocCog(commands.Cog): # 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 item.group in FORCE_PREFIX_GROUPS: + needs_moving = FORCE_PREFIX_GROUPS.index(group_name) < FORCE_PREFIX_GROUPS.index(item.group) + else: + needs_moving = False + return rename(item.group if needs_moving else group_name, rename_extant=needs_moving) # 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. |