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