@@ -177,6 +177,23 @@ def copy_asset_files(app, exception):
177
177
)
178
178
179
179
180
+ def setup_domains (app , config ):
181
+ # Add ``hoverxref`` role replicating the behavior of ``ref``
182
+ app .add_role_to_domain (
183
+ 'std' ,
184
+ 'hoverxref' ,
185
+ XRefRole (
186
+ lowercase = True ,
187
+ innernodeclass = nodes .inline ,
188
+ warn_dangling = True ,
189
+ ),
190
+ )
191
+ app .add_domain (HoverXRefStandardDomain , override = True )
192
+
193
+ if 'py' in config .hoverxref_domains :
194
+ app .add_domain (HoverXRefPythonDomain , override = True )
195
+
196
+
180
197
def setup (app ):
181
198
"""Setup ``hoverxref`` Sphinx extension."""
182
199
@@ -190,6 +207,7 @@ def setup(app):
190
207
app .add_config_value ('hoverxref_auto_ref' , False , 'env' )
191
208
app .add_config_value ('hoverxref_mathjax' , False , 'env' )
192
209
app .add_config_value ('hoverxref_sphinxtabs' , False , 'env' )
210
+ app .add_config_value ('hoverxref_domains' , [], 'env' )
193
211
194
212
app .add_config_value ('hoverxref_tooltip_api_host' , 'https://readthedocs.org' , 'env' )
195
213
app .add_config_value ('hoverxref_tooltip_theme' , ['tooltipster-shadow' , 'tooltipster-shadow-custom' ], 'env' )
@@ -206,20 +224,7 @@ def setup(app):
206
224
# replace this as well
207
225
app .set_translator ('readthedocs' , HoverXRefHTMLTranslator , override = True )
208
226
209
- # Add ``hoverxref`` role replicating the behavior of ``ref``
210
- app .add_role_to_domain (
211
- 'std' ,
212
- 'hoverxref' ,
213
- XRefRole (
214
- lowercase = True ,
215
- innernodeclass = nodes .inline ,
216
- warn_dangling = True ,
217
- ),
218
- )
219
-
220
- app .add_domain (HoverXRefStandardDomain , override = True )
221
- app .add_domain (HoverXRefPythonDomain , override = True )
222
-
227
+ app .connect ('config-inited' , setup_domains )
223
228
app .connect ('build-finished' , copy_asset_files )
224
229
225
230
for f in ASSETS_FILES :
0 commit comments