@@ -291,6 +291,20 @@ def found_tabs_directive(self):
291291 return self ._found
292292
293293
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+
294308# pylint: disable=unused-argument
295309def update_context (app , pagename , templatename , context , doctree ):
296310 """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):
318332def setup (app ):
319333 """Set up the plugin"""
320334 app .add_config_value ("sphinx_tabs_valid_builders" , [], "" )
335+ app .add_config_value ("sphinx_tabs_disable_css_loading" , False , "html" , [bool ])
321336 app .add_config_value ("sphinx_tabs_disable_tab_closing" , False , "html" , [bool ])
322337 app .add_node (SphinxTabsContainer , html = (visit , depart ))
323338 app .add_node (SphinxTabsPanel , html = (visit , depart ))
@@ -332,17 +347,7 @@ def setup(app):
332347 "builder-inited" ,
333348 (lambda app : app .config .html_static_path .append (static_dir .as_posix ())),
334349 )
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 )
346351 app .connect ("html-page-context" , update_context )
347352
348353 return {
0 commit comments