mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6900: sphinx-build: -D option does not considers 0 and 1 as a boolean value
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -87,6 +87,8 @@ Bugs fixed
|
|||||||
* #6876: LaTeX: multi-line display of authors on title page has ragged edges
|
* #6876: LaTeX: multi-line display of authors on title page has ragged edges
|
||||||
* #6887: Sphinx crashes with docutils-0.16b0
|
* #6887: Sphinx crashes with docutils-0.16b0
|
||||||
* #6920: sphinx-build: A console message is wrongly highlighted
|
* #6920: sphinx-build: A console message is wrongly highlighted
|
||||||
|
* #6900: sphinx-build: ``-D`` option does not considers ``0`` and ``1`` as a
|
||||||
|
boolean value
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
|||||||
app.add_config_value('latex_logo', None, None, [str])
|
app.add_config_value('latex_logo', None, None, [str])
|
||||||
app.add_config_value('latex_appendices', [], None)
|
app.add_config_value('latex_appendices', [], None)
|
||||||
app.add_config_value('latex_use_latex_multicolumn', False, None)
|
app.add_config_value('latex_use_latex_multicolumn', False, None)
|
||||||
app.add_config_value('latex_use_xindy', default_latex_use_xindy, None)
|
app.add_config_value('latex_use_xindy', default_latex_use_xindy, None, [bool])
|
||||||
app.add_config_value('latex_toplevel_sectioning', None, None,
|
app.add_config_value('latex_toplevel_sectioning', None, None,
|
||||||
ENUM(None, 'part', 'chapter', 'section'))
|
ENUM(None, 'part', 'chapter', 'section'))
|
||||||
app.add_config_value('latex_domain_indices', True, None, [list])
|
app.add_config_value('latex_domain_indices', True, None, [list])
|
||||||
|
|||||||
@@ -217,6 +217,12 @@ class Config:
|
|||||||
defvalue = self.values[name][0]
|
defvalue = self.values[name][0]
|
||||||
if self.values[name][2] == Any:
|
if self.values[name][2] == Any:
|
||||||
return value
|
return value
|
||||||
|
elif type(defvalue) is bool or self.values[name][2] == [bool]:
|
||||||
|
if value == '0':
|
||||||
|
# given falsy string from command line option
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return bool(value)
|
||||||
elif isinstance(defvalue, dict):
|
elif isinstance(defvalue, dict):
|
||||||
raise ValueError(__('cannot override dictionary config setting %r, '
|
raise ValueError(__('cannot override dictionary config setting %r, '
|
||||||
'ignoring (use %r to set individual elements)') %
|
'ignoring (use %r to set individual elements)') %
|
||||||
|
|||||||
@@ -119,6 +119,20 @@ def test_overrides():
|
|||||||
assert config.value8 == ['abc', 'def', 'ghi']
|
assert config.value8 == ['abc', 'def', 'ghi']
|
||||||
|
|
||||||
|
|
||||||
|
def test_overrides_boolean():
|
||||||
|
config = Config({}, {'value1': '1',
|
||||||
|
'value2': '0',
|
||||||
|
'value3': '0'})
|
||||||
|
config.add('value1', None, 'env', [bool])
|
||||||
|
config.add('value2', None, 'env', [bool])
|
||||||
|
config.add('value3', True, 'env', ())
|
||||||
|
config.init_values()
|
||||||
|
|
||||||
|
assert config.value1 is True
|
||||||
|
assert config.value2 is False
|
||||||
|
assert config.value3 is False
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("sphinx.config.logger")
|
@mock.patch("sphinx.config.logger")
|
||||||
def test_errors_warnings(logger, tempdir):
|
def test_errors_warnings(logger, tempdir):
|
||||||
# test the error for syntax errors in the config file
|
# test the error for syntax errors in the config file
|
||||||
|
|||||||
Reference in New Issue
Block a user