如何在Sphinx主题或扩展构建事件中设置配置值?
我正在构建一个子类主题,该主题是另一个主题,并在sphinx中设置了几个默认配置值(例如,html_theme_options
的值的子集)。
我尝试编写回调事件函数以读取 app.config
如果不存在,则设置一个变量,如这样:
def setup(app):
app.config.html_theme_options["option"] = "value"
但是,“ value”似乎并未传播到Sphinx构建过程中的其他阶段。如果我检查app.config.html_theme_options
,在将其重置为主题之前,我再次具有原始默认值。
我在config-inited
和builder-inited
构建事件,但在任何一种情况下似乎都不起作用。有人知道如何通过自己的主题或扩展而过度乘坐狮身人面像默认值?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论