Hello! (This is a continuation of https://github.com/sphinx-doc/sphinx/issues/1379)
I'm developing an extension for drawing railroad diagrams in svg. So there's a css file with default styles for diagrams which I'd like to see included on every page that uses functionality of my plugin. I, however, was not able to find any API for doing this. I'm looking for a solution that: - will not require user to adjust 'html_static_path' in theirs conf.py. That is, including my extension to the 'extensions' list should be enough for it to work; - will allow user to override the default stylesheet by providing their own one; - (optionally) will only include my css to the pages that actually use directives from my plugin. Public API don't do what I want it to do: - 'app.add_stylesheet' requires that "the filename must be relative to the HTML static path, or a full URI with scheme". Naturally, none of my extension's directory are on HTML static path, thus calling 'app.add_stylesheet' is not enough by itself; - modifying 'app.config.html_static_path' from the setup function of my extension only works if user have not redefined 'html_static_path' in theirs conf.py. This happens because variables from conf.py override default config variables after all extensions re loaded; - modifying 'app.config._raw_config['html_static_path']' does exactly what I want, however, '_raw_config' is not part of the public API; - modifying 'app.config.html_static_path' from 'builder-inited' hook seems to work (that's how exhale does this) but Shimizukawa suggests <https://github.com/sphinx-doc/sphinx/issues/1379#issuecomment-439657133> that extensions should not modify 'app.config'. So, there seem to be no way to add custom stylesheets and javascript files from extensions *properly*. I propose either developing an official API for this or stating that modifying 'app.config' from 'builder-inited' is fine (or maybe we should use 'config-inited' for this?) and documenting this usage. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
