@@ -291,6 +291,20 @@ def found_tabs_directive(self):
291
291
return self ._found
292
292
293
293
294
+ def update_config (app , config ):
295
+ """Adds sphinx-tabs CSS and JS asset files"""
296
+ for path in [Path (path ) for path in FILES ]:
297
+ if not config .sphinx_tabs_disable_css_loading and path .suffix == ".css" :
298
+ if "add_css_file" in dir (app ):
299
+ app .add_css_file (path .as_posix ())
300
+ else :
301
+ app .add_stylesheet (path .as_posix ())
302
+ if path .suffix == ".js" :
303
+ if "add_script_file" in dir (app ):
304
+ app .add_script_file (path .as_posix ())
305
+ else :
306
+ app .add_js_file (path .as_posix ())
307
+
294
308
# pylint: disable=unused-argument
295
309
def update_context (app , pagename , templatename , context , doctree ):
296
310
"""Remove sphinx-tabs CSS and JS asset files if not used in a page"""
@@ -318,6 +332,7 @@ def update_context(app, pagename, templatename, context, doctree):
318
332
def setup (app ):
319
333
"""Set up the plugin"""
320
334
app .add_config_value ("sphinx_tabs_valid_builders" , [], "" )
335
+ app .add_config_value ("sphinx_tabs_disable_css_loading" , False , "html" , [bool ])
321
336
app .add_config_value ("sphinx_tabs_disable_tab_closing" , False , "html" , [bool ])
322
337
app .add_node (SphinxTabsContainer , html = (visit , depart ))
323
338
app .add_node (SphinxTabsPanel , html = (visit , depart ))
@@ -332,17 +347,7 @@ def setup(app):
332
347
"builder-inited" ,
333
348
(lambda app : app .config .html_static_path .append (static_dir .as_posix ())),
334
349
)
335
- for path in [Path (path ) for path in FILES ]:
336
- if path .suffix == ".css" :
337
- if "add_css_file" in dir (app ):
338
- app .add_css_file (path .as_posix ())
339
- else :
340
- app .add_stylesheet (path .as_posix ())
341
- if path .suffix == ".js" :
342
- if "add_script_file" in dir (app ):
343
- app .add_script_file (path .as_posix ())
344
- else :
345
- app .add_js_file (path .as_posix ())
350
+ app .connect ("config-inited" , update_config )
346
351
app .connect ("html-page-context" , update_context )
347
352
348
353
return {
0 commit comments