@@ -679,6 +679,34 @@ def process_audit_events(app, doctree, fromdocname):
679679 node .replace_self (table )
680680
681681
682+ def patch_pairindextypes (app ) -> None :
683+ if app .builder .name != 'gettext' :
684+ return
685+
686+ # allow translating deprecated index entries
687+ try :
688+ from sphinx .domains .python import pairindextypes
689+ except ImportError :
690+ pass
691+ else :
692+ # Sphinx checks if a 'pair' type entry on an index directive is one of
693+ # the Sphinx-translated pairindextypes values. As we intend to move
694+ # away from this, we need Sphinx to believe that these values don't
695+ # exist, by deleting them when using the gettext builder.
696+
697+ # pairindextypes.pop('module', None)
698+ # pairindextypes.pop('keyword', None)
699+ # pairindextypes.pop('operator', None)
700+ # pairindextypes.pop('object', None)
701+ # pairindextypes.pop('exception', None)
702+ # pairindextypes.pop('statement', None)
703+ # pairindextypes.pop('builtin', None)
704+
705+ # there needs to be at least one statement in this block, will be
706+ # removed when the first of the below is uncommented.
707+ pass
708+
709+
682710def setup (app ):
683711 app .add_role ('issue' , issue_role )
684712 app .add_role ('gh' , gh_issue_role )
@@ -701,6 +729,7 @@ def setup(app):
701729 app .add_directive_to_domain ('py' , 'awaitablemethod' , PyAwaitableMethod )
702730 app .add_directive_to_domain ('py' , 'abstractmethod' , PyAbstractMethod )
703731 app .add_directive ('miscnews' , MiscNews )
732+ app .connect ('builder-inited' , patch_pairindextypes )
704733 app .connect ('doctree-resolved' , process_audit_events )
705734 app .connect ('env-merge-info' , audit_events_merge )
706735 app .connect ('env-purge-doc' , audit_events_purge )
0 commit comments