2012-12-27 17 views
2

試圖增加每文檔一個簡單的真/假值這裏:獅身人面像add_config_value不添加變量

http://sphinx-doc.org/ext/ifconfig.html

在我conf.py文件:

extensions = ['sphinx.ext.todo', 'sphinx.ext.ifconfig'] 

# Custom variables 
def setup(app): 
    app.add_config_value('responsiveenabled', True, True) 

在我grids.rst文件(網頁來描述如何建立一個自舉網格),我有這樣的:

.. ifconfig:: responsiveenabled 

Blah blah blah. 

我得到的錯誤是:

NameError: name 'responsiveenabled' is not defined 

我需要的responsiveenabled後的東西,像 「在(...)」?我想保持它不知道我正在寫的文檔的哪個版本。

回答

2

conf.py文件應該是:

extensions = ['sphinx.ext.todo', 'sphinx.ext.ifconfig'] 

# Custom variables 
def setup(app): 
    app.add_config_value('responsiveenabled', True, True) 

responsiveenabled = True 

我知道這應該是一個默認值,但我無法得到它的工作 沒有初始化。

那麼你可以使用

.. ifconfig:: responsiveenabled 

    text included if the config variable is set 

text always included