From e2aaa2860997606104da865dfaff58f5ce2dfd65 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Tue, 16 Jan 2018 22:08:06 -0500 Subject: [PATCH 1/4] Don't require numfig to use :numref: on sections Tweak logic that rejects a :numref: if numfig is not on to bypass this check if the reference is a section. Section numbers are applied independent of numfig, so the check is not needed, and makes it needlessly difficult to use :numref: if the user only cares about using it on sections. --- sphinx/domains/std.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index bfaa57c4f..686945321 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -715,15 +715,15 @@ class StandardDomain(Domain): if not docname: return None - if env.config.numfig is False: - logger.warning('numfig is disabled. :numref: is ignored.', location=node) - return contnode - target_node = env.get_doctree(docname).ids.get(labelid) figtype = self.get_figtype(target_node) if figtype is None: return None + if figtype != 'section' and env.config.numfig is False: + logger.warning('numfig is disabled. :numref: is ignored.', location=node) + return contnode + try: fignumber = self.get_fignumber(env, builder, figtype, docname, target_node) if fignumber is None: From 11fa47769b8b813fb2815111d8d27ebb560b58a4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 7 Mar 2018 10:43:14 +0900 Subject: [PATCH 2/4] Fix filename of epub (refs: #4611) --- tests/test_build_epub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py index ef2e4d87d..3256fcb9f 100644 --- a/tests/test_build_epub.py +++ b/tests/test_build_epub.py @@ -267,7 +267,7 @@ def test_run_epubcheck(app): epubcheck = os.environ.get('EPUBCHECK_PATH', '/usr/share/java/epubcheck.jar') if runnable('java') and os.path.exists(epubcheck): - p = Popen(['java', '-jar', epubcheck, app.outdir / 'Sphinx.epub'], + p = Popen(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'], stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() if p.returncode != 0: From 31db987d681ec32c27281d1e4bf22283cca5b7bd Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 8 Mar 2018 01:11:07 +0900 Subject: [PATCH 3/4] Update testcases --- tests/test_build_html.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_build_html.py b/tests/test_build_html.py index ceeb5f01c..7e574ac56 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -537,7 +537,6 @@ def test_numfig_disabled_warn(app, warning): app.build() warnings = warning.getvalue() assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' in warnings - assert 'index.rst:55: WARNING: no number is assigned for section: index' not in warnings assert 'index.rst:56: WARNING: invalid numfig_format: invalid' not in warnings assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' not in warnings @@ -555,10 +554,10 @@ def test_numfig_disabled_warn(app, warning): (".//li/code/span", '^Table:%s$', True), (".//li/code/span", '^CODE_1$', True), (".//li/code/span", '^Code-%s$', True), - (".//li/code/span", '^foo$', True), - (".//li/code/span", '^bar_a$', True), + (".//li/a/span", '^Section 1$', True), + (".//li/a/span", '^Section 2.1$', True), (".//li/code/span", '^Fig.{number}$', True), - (".//li/code/span", '^Sect.{number}$', True), + (".//li/a/span", '^Sect.1 Foo$', True), ], 'foo.html': [ (".//div[@class='figure']/p[@class='caption']/" From 8b0812edc241043e006cf8bb9ee453efcd2c0493 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 8 Mar 2018 01:12:10 +0900 Subject: [PATCH 4/4] Update CHANGES for PR #4444 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 7bd94f54a..c82fcf811 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugs fixed * pydomain: always strip parenthesis if empty (refs: #1042) * #4689: autosummary: unexpectedly strips docstrings containing "i.e." * #4701: viewcode: Misplaced ``
`` in viewcode html output +* #4444: Don't require numfig to use :numref: on sections Testing --------