From 1977f3fceeab1f9132a5096993f243f1a76fd0f5 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 20 Dec 2020 02:18:56 +0900 Subject: [PATCH] Fix #8549: i18n: ``-D gettext_compact=0`` is no longer working Since 1bf7fe424, ``-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]`. --- CHANGES | 1 + sphinx/builders/gettext.py | 2 +- sphinx/config.py | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 327dc5e43ee..e6552d7fc5f 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index cbc6fc4441e..0056184ff81 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -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') diff --git a/sphinx/config.py b/sphinx/config.py index b3cd1dc6dbf..13159d2d2b2 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -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