4

Trying to add a simple true/false value per the docs here:

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

In my conf.py file:

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

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

In my grids.rst file (a page to describe how to set up a bootstrap grid), I have this:

.. ifconfig:: responsiveenabled

Blah blah blah.

The error I'm getting is:

NameError: name 'responsiveenabled' is not defined

Do I need something after the responsiveenabled, like "in (...)"? I'd like to keep it agnostic to which version of the docs I'm writing.

Adam Grant
  • 12,477
  • 10
  • 58
  • 65

1 Answers1

3

Your conf.py file should be:

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

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

responsiveenabled = True

I know it is supposed to be a default value, but I could not get it work without init.

then you can use

.. ifconfig:: responsiveenabled

   text included if the config variable is set

text always included
marcz
  • 1,178
  • 11
  • 12