diff options
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | sphinx/domains/cpp.py | 4 | ||||
-rw-r--r-- | sphinx/environment/__init__.py | 13 | ||||
-rw-r--r-- | sphinx/themes/basic/static/searchtools.js_t | 3 | ||||
-rw-r--r-- | sphinx/util/logging.py | 10 | ||||
-rw-r--r-- | tests/roots/test-domain-cpp/roles2.rst | 5 | ||||
-rw-r--r-- | tests/test_domain_cpp.py | 7 | ||||
-rw-r--r-- | tests/test_util_logging.py | 6 |
8 files changed, 41 insertions, 12 deletions
@@ -92,12 +92,17 @@ Deprecated Features added -------------- +* #4107: Make searchtools.js compatible with pre-Sphinx1.5 templates +* #4112: Don't override the smart_quotes setting if it was already set + Bugs fixed ---------- * #4085: Failed PDF build from image in parsed-literal using ``:align:`` option * #4100: Remove debug print from autodoc extension * #3987: Changing theme from alabaster causes HTML build to fail +* #4096: C++, don't crash when using the wrong role type. Thanks to mitya57. +* #4070, #4111: crashes when the warning message contains format strings (again) Testing -------- diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 95ebcf165..bdda12473 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -5614,8 +5614,8 @@ class CPPDomain(Domain): if declTyp == 'templateParam': return True objtypes = self.objtypes_for_role(typ) - if objtypes and declTyp in objtypes: - return True + if objtypes: + return declTyp in objtypes print("Type is %s, declType is %s" % (typ, declTyp)) assert False if not checkType(): diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 30763adcd..92f16d7cf 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -675,12 +675,13 @@ class BuildEnvironment(object): language = self.config.language or 'en' self.settings['language_code'] = language - self.settings['smart_quotes'] = True - for tag in normalize_language_tag(language): - if tag in smartchars.quotes: - break - else: - self.settings['smart_quotes'] = False + if 'smart_quotes' not in self.settings: + self.settings['smart_quotes'] = True + for tag in normalize_language_tag(language): + if tag in smartchars.quotes: + break + else: + self.settings['smart_quotes'] = False docutilsconf = path.join(self.srcdir, 'docutils.conf') # read docutils.conf from source dir, not from current dir diff --git a/sphinx/themes/basic/static/searchtools.js_t b/sphinx/themes/basic/static/searchtools.js_t index 149d1624d..306fdf55f 100644 --- a/sphinx/themes/basic/static/searchtools.js_t +++ b/sphinx/themes/basic/static/searchtools.js_t @@ -269,6 +269,9 @@ var Search = { }); } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX; + if (suffix === undefined) { + suffix = '.txt'; + } $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix), dataType: "text", complete: function(jqxhr, textstatus) { diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index 2cdac6c40..7fb5c5894 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -356,11 +356,15 @@ class WarningIsErrorFilter(logging.Filter): return True elif self.app.warningiserror: location = getattr(record, 'location', '') - message = record.msg.replace('%', '%%') + try: + message = record.msg % record.args + except TypeError: + message = record.msg # use record.msg itself + if location: - raise SphinxWarning(location + ":" + message % record.args) + raise SphinxWarning(location + ":" + message) else: - raise SphinxWarning(message % record.args) + raise SphinxWarning(message) else: return True diff --git a/tests/roots/test-domain-cpp/roles2.rst b/tests/roots/test-domain-cpp/roles2.rst new file mode 100644 index 000000000..644b827ca --- /dev/null +++ b/tests/roots/test-domain-cpp/roles2.rst @@ -0,0 +1,5 @@ +Check that we don't crash just because we misuse a role. + +.. cpp:class:: A + +:cpp:func:`A` diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 1229e550d..8c0fae2e3 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -598,6 +598,13 @@ def test_attributes(): # raise DefinitionError("") +@pytest.mark.sphinx(testroot='domain-cpp') +def test_build_domain_cpp_misuse_of_roles(app, status, warning): + app.builder.build_all() + + # TODO: properly check for the warnings we expect + + @pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'add_function_parentheses': True}) def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, warning): app.builder.build_all() diff --git a/tests/test_util_logging.py b/tests/test_util_logging.py index 717aa6cd4..7ae086872 100644 --- a/tests/test_util_logging.py +++ b/tests/test_util_logging.py @@ -165,7 +165,11 @@ def test_warningiserror(app, status, warning): # if True, warning raises SphinxWarning exception app.warningiserror = True with pytest.raises(SphinxWarning): - logger.warning('message') + logger.warning('message: %s', 'arg') + + # message contains format string (refs: #4070) + with pytest.raises(SphinxWarning): + logger.warning('%s') def test_warning_location(app, status, warning): |