相关疑难解决方法(0)

如何在conf.py中为sphinx设置自定义配置值?(例如,对于sphinx.ext.ifconfig)

[经过更多的测试和研究后,我把原来的问题分成了两个]

我在conf.py中定义了自己的配置值,并编写了一个最小扩展名,以便从第一个文件中看到它.

在conf.py中:

sys.path.insert(0, os.path.abspath('.'))
extensions = ['sphinx.ext.ifconfig', 'myExt']
testlevel = 2
Run Code Online (Sandbox Code Playgroud)

在本地myExt.py中:

def setup(app):
   app.add_config_value('testlevel', '', True)
Run Code Online (Sandbox Code Playgroud)

这很好用; test.rst包括:

.. ifconfig:: testlevel == 2

    Hurray, it seems to work
Run Code Online (Sandbox Code Playgroud)

根据sphinx.ext.ifconfig的文档,似乎可以直接从conf.py调用*app.add_config_value*.谁能告诉我怎么做?

python-sphinx

5
推荐指数
1
解决办法
2534
查看次数

标签 统计

python-sphinx ×1