From d790c404ca3dba3843f351d6f42e766956aa73a1 Mon Sep 17 00:00:00 2001 From: Numerlor <25886452+Numerlor@users.noreply.github.com> Date: Sun, 21 Jun 2020 02:37:32 +0200 Subject: Renamed existing symbols from `NO_OVERRIDE_GROUPS` instead of replacing. Before, when a symbol from the group shared the name with a symbol outside of it the symbol was simply replaced and lost. The new implementation renames the old symbols to the group_name.symbol format before the new symbol takes their place. --- bot/cogs/doc.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py index 741fd0ddd..4eea06386 100644 --- a/bot/cogs/doc.py +++ b/bot/cogs/doc.py @@ -209,16 +209,21 @@ class Doc(commands.Cog): group_name in NO_OVERRIDE_GROUPS or any(package in symbol_base_url for package in NO_OVERRIDE_PACKAGES) ): - symbol = f"{group_name}.{symbol}" - # If renamed `symbol` already exists, add library name in front to differentiate between them. - if symbol in self.renamed_symbols: - # Split `package_name` because of packages like Pillow that have spaces in them. - symbol = f"{package_name.split()[0]}.{symbol}" - self.inventories[symbol] = DocItem(absolute_doc_url, group_name) + elif (overridden_symbol_group := self.inventories[symbol].group) in NO_OVERRIDE_GROUPS: + overridden_symbol = f"{overridden_symbol_group}.{symbol}" + if overridden_symbol in self.renamed_symbols: + overridden_symbol = f"{package_name.split()[0]}.{overridden_symbol}" + + self.inventories[overridden_symbol] = self.inventories[symbol] + self.renamed_symbols.add(overridden_symbol) + + # If renamed `symbol` already exists, add library name in front to differentiate between them. + if symbol in self.renamed_symbols: + # Split `package_name` because of packages like Pillow that have spaces in them. + symbol = f"{package_name.split()[0]}.{symbol}" self.renamed_symbols.add(symbol) - continue self.inventories[symbol] = DocItem(absolute_doc_url, group_name) -- cgit v1.2.3