how to set a custom config value for sphinx in conf.py? (e.g., for sphinx.ext.ifconfig)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: [I split the original question into two after more testing and research] I defined my own configuration value in conf.py and wrote a minimal extension to make it visible from rst files. in conf.py: sys.path.insert(0, os.path.abspath('.')) extensions = ['sphinx.ext.ifconfig', 'myExt'] testlevel = 2 in a local myExt.py: def setup(app): app.add_config_value('testlevel', '', True) This works just fine; test.rst includes: .. ifconfig:: testlevel == 2 Hurray, it seems to work According to the doc of sphinx.ext.ifconfig , it seems possible to call