Skip to content

Commit

Permalink
Fix #8549: i18n: -D gettext_compact=0 is no longer working
Browse files Browse the repository at this point in the history
Since 1bf7fe4, ``-D gettext_compact=0`` is not treated as disabling
the feature.  It is recognized as creating ``0.pot`` because its type is
Any.  This changes it to `[bool, str]`.
  • Loading branch information
tk0miya committed Dec 20, 2020
1 parent aae2f19 commit 1977f3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Bugs fixed
* #8501: autosummary: summary extraction splits text after "el at." unexpectedly
* #8524: html: Wrong url_root has been generated on a document named "index"
* #8419: html search: Do not load ``language_data.js`` in non-search pages
* #8549: i18n: ``-D gettext_compact=0`` is no longer working
* #8454: graphviz: The layout option for graph and digraph directives don't work
* #8131: linkcheck: Use GET when HEAD requests cause Too Many Redirects, to
accommodate infinite redirect loops on HEAD
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def finish(self) -> None:
def setup(app: Sphinx) -> Dict[str, Any]:
app.add_builder(MessageCatalogBuilder)

app.add_config_value('gettext_compact', True, 'gettext', Any)
app.add_config_value('gettext_compact', True, 'gettext', {bool, str})
app.add_config_value('gettext_location', True, 'gettext')
app.add_config_value('gettext_uuid', False, 'gettext')
app.add_config_value('gettext_auto_build', True, 'env')
Expand Down
8 changes: 8 additions & 0 deletions sphinx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def convert_overrides(self, name: str, value: Any) -> Any:
defvalue = self.values[name][0]
if self.values[name][2] == Any:
return value
elif self.values[name][2] == {bool, str}:
if value == '0':
# given falsy string from command line option
return False
elif value == '1':
return True
else:
return value
elif type(defvalue) is bool or self.values[name][2] == [bool]:
if value == '0':
# given falsy string from command line option
Expand Down

0 comments on commit 1977f3f

Please sign in to comment.