【问题标题】:Sphinx add_config_value not adding variable狮身人面像 add_config_value 不添加变量
【发布时间】:2012-12-27 20:02:24
【问题描述】:

尝试在此处根据文档添加一个简单的真/假值:

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 之后我需要一些东西,比如“in (...)”吗?我想让它与我正在编写的文档版本无关。

【问题讨论】:

    标签: python django python-sphinx django-sphinx


    【解决方案1】:

    您的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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      相关资源
      最近更新 更多