Allow giving values for dict type config values in the overrides.

This commit is contained in:
Georg Brandl
2008-11-30 16:33:56 +01:00
parent bd12a8e547
commit 2757866655
4 changed files with 27 additions and 3 deletions

12
CHANGES
View File

@@ -1,3 +1,15 @@
Release 0.6 (in development)
============================
New features added
------------------
* Other changes:
- Allow giving config overrides for single dict keys on the command
line.
Release 0.5 (Nov 23, 2008) -- Birthday release!
===============================================

View File

@@ -111,8 +111,12 @@ The :program:`sphinx-build` script has several more options:
.. versionadded:: 0.5
**-D** *setting=value*
Override a configuration value set in the :file:`conf.py` file. (The value
must be a string value.)
Override a configuration value set in the :file:`conf.py` file. The value
must be a string or dictionary value. For the latter, supply the setting
name and key like this: ``-D latex_elements.docclass=scrartcl``.
.. versionchanged:: 0.6
The value can now be a dictionary value.
**-A** *name=value*
Make the *name* assigned to *value* in the HTML templates.

View File

@@ -111,6 +111,12 @@ class Config(object):
def init_values(self):
config = self._raw_config
for valname, value in self.overrides.iteritems():
if '.' in valname:
realvalname, key = valname.split('.', 1)
config.setdefault(realvalname, {})[key] = value
else:
config[valname] = value
config.update(self.overrides)
for name in config:
if name in self.values:

View File

@@ -15,7 +15,8 @@ from util import *
from sphinx.application import ExtensionError
@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True'})
@with_app(confoverrides={'master_doc': 'master', 'nonexisting_value': 'True',
'latex_elements.docclass': 'scrartcl'})
def test_core_config(app):
cfg = app.config
@@ -26,6 +27,7 @@ def test_core_config(app):
# overrides
assert cfg.master_doc == 'master'
assert cfg.latex_elements['docclass'] == 'scrartcl'
# simple default values
assert 'exclude_dirs' not in cfg.__dict__