How to set configuration values in Sphinx theme or extension build event?

Viewed 19

I am building a Sphinx theme that sub-classes another theme, and sets several default configuration values in Sphinx (for example, a subset of values of html_theme_options).

I have tried writing a callback event function to read app.config and set a variable if it does not exist, like this:

def setup(app):
    app.config.html_theme_options["option"] = "value"

However, "value" does not seem to propagate to other stages in the Sphinx build process. If I inspect app.config.html_theme_options, I once again have the original default value before I reset it in my theme.

I have tried the same pattern in the config-inited and builder-inited build events, but it doesn't seem to work in either case. Does anybody know how to over-ride Sphinx defaults via your own theme or extension?

0 Answers
Related