From f2ba53f20b3902b5cc12f014e11251402603d90f Mon Sep 17 00:00:00 2001 From: Luc Saffre Date: Wed, 6 Mar 2019 09:49:52 +0200 Subject: [PATCH 1/6] Fixed a bug in intersphinx failure reporting --- sphinx/ext/intersphinx.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 33e218531..313fc8970 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -183,7 +183,7 @@ def fetch_inventory(app, uri, inv): f = open(path.join(app.srcdir, inv), 'rb') except Exception as err: err.args = ('intersphinx inventory %r not fetchable due to %s: %s', - inv, err.__class__, err) + inv, err.__class__, str(err)) raise try: if hasattr(f, 'url'): @@ -201,7 +201,7 @@ def fetch_inventory(app, uri, inv): raise ValueError('unknown or unsupported inventory version: %r' % exc) except Exception as err: err.args = ('intersphinx inventory %r not readable due to %s: %s', - inv, err.__class__.__name__, err) + inv, err.__class__.__name__, str(err)) raise else: return invdata @@ -265,10 +265,9 @@ def load_mappings(app): for fail in failures: logger.info(*fail) else: + issues = '\n'.join([f[0] % f[1:] for f in failures]) logger.warning(__("failed to reach any of the inventories " - "with the following issues:")) - for fail in failures: - logger.warning(*fail) + "with the following issues:") + "\n" + issues) if update: inventories.clear() From 2f97fd4b0c73f2c50402eb5e0287a712b378fe30 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Mar 2019 22:15:36 +0900 Subject: [PATCH 2/6] Update CHANGES for PR #6139, #6148 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 41c5212c2..048989a41 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugs fixed * #6028: graphviz: Ensure the graphviz filenames are reproducible * #6068: doctest: ``skipif`` option may remove the code block from documentation * #6136: ``:name:`` option for ``math`` directive causes a crash +* #6139: intersphinx: ValueError on failure reporting Testing -------- From 71dec3b38e8231125bcc25b3bf6e484df921194f Mon Sep 17 00:00:00 2001 From: Martin Packman Date: Mon, 4 Mar 2019 15:58:12 +0000 Subject: [PATCH 3/6] Fix UnboundLocalError when building changes Split testing of changes builder to its own test file and root. Improve coverage a little, and add case that fails if a module directive is included in the rst source. Correctly handle changesets with a module declared. Fixes https://github.com/sphinx-doc/sphinx/issues/6134 --- sphinx/builders/changes.py | 3 +- tests/roots/test-changes/base.rst | 20 ++++++++++ tests/roots/test-changes/c-api.rst | 24 ++++++++++++ tests/roots/test-changes/conf.py | 6 +++ tests/roots/test-changes/contents.rst | 13 +++++++ tests/roots/test-changes/library/utils.rst | 25 +++++++++++++ tests/test_build.py | 4 +- tests/test_build_changes.py | 43 ++++++++++++++++++++++ 8 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 tests/roots/test-changes/base.rst create mode 100644 tests/roots/test-changes/c-api.rst create mode 100644 tests/roots/test-changes/conf.py create mode 100644 tests/roots/test-changes/contents.rst create mode 100644 tests/roots/test-changes/library/utils.rst create mode 100644 tests/test_build_changes.py diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index 308ae9656..aa5fea5a5 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -85,8 +85,7 @@ class ChangesBuilder(Builder): entry = '%s: %s.' % (descname, ttext) apichanges.append((entry, changeset.docname, changeset.lineno)) elif descname or changeset.module: - if not changeset.module: - module = _('Builtins') + module = changeset.module or _('Builtins') if not descname: descname = _('Module level') if context: diff --git a/tests/roots/test-changes/base.rst b/tests/roots/test-changes/base.rst new file mode 100644 index 000000000..a1b28398a --- /dev/null +++ b/tests/roots/test-changes/base.rst @@ -0,0 +1,20 @@ +Version markup +-------------- + +.. versionadded:: 0.6 + Some funny **stuff**. + +.. versionchanged:: 0.6 + Even more funny stuff. + +.. deprecated:: 0.6 + Boring stuff. + +.. versionadded:: 1.2 + + First paragraph of versionadded. + +.. versionchanged:: 1.2 + First paragraph of versionchanged. + + Second paragraph of versionchanged. diff --git a/tests/roots/test-changes/c-api.rst b/tests/roots/test-changes/c-api.rst new file mode 100644 index 000000000..22c0c30c6 --- /dev/null +++ b/tests/roots/test-changes/c-api.rst @@ -0,0 +1,24 @@ +.. highlightlang:: c + + +Memory +====== + +.. c:function:: void* Test_Malloc(size_t n) + + Allocate *n* bytes of memory. + + .. versionchanged:: 0.6 + + Can now be replaced with a different allocator. + +System +------ + +Access to the system allocator. + +.. versionadded:: 0.6 + +.. c:function:: void* Test_SysMalloc(size_t n) + + Allocate *n* bytes of memory using system allocator. diff --git a/tests/roots/test-changes/conf.py b/tests/roots/test-changes/conf.py new file mode 100644 index 000000000..94cb629dc --- /dev/null +++ b/tests/roots/test-changes/conf.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +project = 'Sphinx ChangesBuilder tests' +copyright = '2007-2019 by the Sphinx team, see AUTHORS' +version = '0.6' +release = '0.6alpha1' diff --git a/tests/roots/test-changes/contents.rst b/tests/roots/test-changes/contents.rst new file mode 100644 index 000000000..ced802608 --- /dev/null +++ b/tests/roots/test-changes/contents.rst @@ -0,0 +1,13 @@ +Index for ChangesBuilder tests +============================== + +Contents: + +.. toctree:: + :maxdepth: 2 + :caption: Table of Contents + :name: mastertoc + + base + c-api + library/utils diff --git a/tests/roots/test-changes/library/utils.rst b/tests/roots/test-changes/library/utils.rst new file mode 100644 index 000000000..86446995b --- /dev/null +++ b/tests/roots/test-changes/library/utils.rst @@ -0,0 +1,25 @@ +:mod:`utils` --- Fake utilities module for tests +================================================ + +.. module:: utils + :synopsis: Utility functions + +-------------- + +The :mod:`utils` module is a pretend python module for changes testing. + + +Classes +------- + +.. class:: Path + + Class for handling paths. + + .. versionadded:: 0.5 + + Innovative new way to handle paths. + + .. deprecated:: 0.6 + + So, that was a bad idea it turns out. diff --git a/tests/test_build.py b/tests/test_build.py index 857e3c8b7..e2243a869 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -61,13 +61,13 @@ def nonascii_srcdir(request, rootdir, sphinx_test_tempdir): # note: this test skips building docs for some builders because they have independent testcase. -# (html, epub, latex, texinfo and manpage) +# (html, changes, epub, latex, texinfo and manpage) @pytest.mark.parametrize( "buildername", [ # note: no 'html' - if it's ok with dirhtml it's ok with html 'dirhtml', 'singlehtml', 'pickle', 'json', 'text', 'htmlhelp', 'qthelp', - 'applehelp', 'changes', 'xml', 'pseudoxml', 'linkcheck', + 'applehelp', 'xml', 'pseudoxml', 'linkcheck', ], ) @mock.patch('sphinx.builders.linkcheck.requests.head', diff --git a/tests/test_build_changes.py b/tests/test_build_changes.py new file mode 100644 index 000000000..911dcd0d1 --- /dev/null +++ b/tests/test_build_changes.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +""" + test_build_changes + ~~~~~~~~~~~~~~~~~~ + + Test the ChangesBuilder class. + + :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import pytest + + +@pytest.mark.sphinx('changes', testroot='changes') +def test_build(app): + app.build() + + # TODO: Use better checking of html content + htmltext = (app.outdir / 'changes.html').text() + assert 'New in version 0.6: Some funny stuff.' in htmltext + assert 'Changed in version 0.6: Even more funny stuff.' in htmltext + assert 'Deprecated since version 0.6: Boring stuff.' in htmltext + + path_html = ( + 'Path: deprecated: Deprecated since version 0.6:' + ' So, that was a bad idea it turns out.') + assert path_html in htmltext + + malloc_html = ( + 'Test_Malloc: changed: Changed in version 0.6:' + ' Can now be replaced with a different allocator.') + assert malloc_html in htmltext + + +@pytest.mark.sphinx( + 'changes', testroot='changes', srcdir='changes-none', + confoverrides={'version': '0.7', 'release': '0.7b1'}) +def test_no_changes(app, status): + app.build() + + assert 'no changes in version 0.7.' in status.getvalue() + assert not (app.outdir / 'changes.html').exists() From f03c2d4fe22500e751a17a84d299cf5f0de901ee Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Mar 2019 15:52:05 +0900 Subject: [PATCH 4/6] Update CHANGES for PR #6135 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 048989a41..ffc8b8b32 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,7 @@ Bugs fixed * #6068: doctest: ``skipif`` option may remove the code block from documentation * #6136: ``:name:`` option for ``math`` directive causes a crash * #6139: intersphinx: ValueError on failure reporting +* #6135: changes: Fix UnboundLocalError when any module found Testing -------- From f7315edfc28cb9712872f02da60945e7e28802ce Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Mar 2019 17:57:20 +0900 Subject: [PATCH 5/6] Use bionic (py36) on Circle CI --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d349db6e0..6ca62abb7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,6 @@ jobs: working_directory: /sphinx steps: - checkout - - run: /python3.5/bin/pip install -U pip setuptools - - run: /python3.5/bin/pip install -U .[test,websupport] - - run: make test PYTHON=/python3.5/bin/python + - run: /python3.6/bin/pip install -U pip setuptools + - run: /python3.6/bin/pip install -U .[test,websupport] + - run: make test PYTHON=/python3.6/bin/python From f61a5f91f75556c3e886fbef7621acd77760bf51 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 3 Feb 2019 23:59:15 +0900 Subject: [PATCH 6/6] Fix test: imgconverter expects size of images fixed --- tests/roots/test-ext-imgconverter/svgimg.svg | 2 +- tests/roots/test-images/subdir/svgimg.svg | 2 +- tests/roots/test-images/subdir/svgimg.xx.svg | 2 +- tests/roots/test-root/svgimg.svg | 2 +- tests/roots/test-warnings/svgimg.svg | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/roots/test-ext-imgconverter/svgimg.svg b/tests/roots/test-ext-imgconverter/svgimg.svg index 533a9fa65..2bae0b9b9 100644 --- a/tests/roots/test-ext-imgconverter/svgimg.svg +++ b/tests/roots/test-ext-imgconverter/svgimg.svg @@ -1,4 +1,4 @@ - + diff --git a/tests/roots/test-images/subdir/svgimg.svg b/tests/roots/test-images/subdir/svgimg.svg index 533a9fa65..2bae0b9b9 100644 --- a/tests/roots/test-images/subdir/svgimg.svg +++ b/tests/roots/test-images/subdir/svgimg.svg @@ -1,4 +1,4 @@ - + diff --git a/tests/roots/test-images/subdir/svgimg.xx.svg b/tests/roots/test-images/subdir/svgimg.xx.svg index 533a9fa65..2bae0b9b9 100644 --- a/tests/roots/test-images/subdir/svgimg.xx.svg +++ b/tests/roots/test-images/subdir/svgimg.xx.svg @@ -1,4 +1,4 @@ - + diff --git a/tests/roots/test-root/svgimg.svg b/tests/roots/test-root/svgimg.svg index 533a9fa65..2bae0b9b9 100644 --- a/tests/roots/test-root/svgimg.svg +++ b/tests/roots/test-root/svgimg.svg @@ -1,4 +1,4 @@ - + diff --git a/tests/roots/test-warnings/svgimg.svg b/tests/roots/test-warnings/svgimg.svg index 533a9fa65..2bae0b9b9 100644 --- a/tests/roots/test-warnings/svgimg.svg +++ b/tests/roots/test-warnings/svgimg.svg @@ -1,4 +1,4 @@ - +