@@ -674,6 +674,34 @@ def process_audit_events(app, doctree, fromdocname):
674
674
node .replace_self (table )
675
675
676
676
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
+
677
705
def setup (app ):
678
706
app .add_role ('issue' , issue_role )
679
707
app .add_role ('gh' , gh_issue_role )
@@ -695,6 +723,7 @@ def setup(app):
695
723
app .add_directive_to_domain ('py' , 'awaitablemethod' , PyAwaitableMethod )
696
724
app .add_directive_to_domain ('py' , 'abstractmethod' , PyAbstractMethod )
697
725
app .add_directive ('miscnews' , MiscNews )
726
+ app .connect ('builder-inited' , patch_pairindextypes )
698
727
app .connect ('doctree-resolved' , process_audit_events )
699
728
app .connect ('env-merge-info' , audit_events_merge )
700
729
app .connect ('env-purge-doc' , audit_events_purge )
0 commit comments