From 00f476040e30371044437860ef07cb023b94489a Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 21 Aug 2018 21:59:16 +0900 Subject: [PATCH 1/8] graphviz: Don't use document.current_source --- sphinx/ext/graphviz.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index a702e6045..cf606f3b7 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -156,9 +156,7 @@ class Graphviz(SphinxDirective): line=self.lineno)] node = graphviz() node['code'] = dotcode - node['options'] = { - 'docname': path.splitext(self.state.document.current_source)[0], - } + node['options'] = {'docname': self.env.docname} if 'graphviz_dot' in self.options: node['options']['graphviz_dot'] = self.options['graphviz_dot'] From 472001eeb754a2389740115de53ae0c129a5eca0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 22 Aug 2018 11:08:33 +0900 Subject: [PATCH 2/8] Fix typo --- doc/usage/extensions/autodoc.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/usage/extensions/autodoc.rst b/doc/usage/extensions/autodoc.rst index 97ac51903..d33378435 100644 --- a/doc/usage/extensions/autodoc.rst +++ b/doc/usage/extensions/autodoc.rst @@ -362,7 +362,7 @@ There are also new config values that you can set: .. confval:: autodoc_default_options The default options for autodoc directives. They are applied to all autodoc - directives automatically. It must be a dictionally which maps option names + directives automatically. It must be a dictionary which maps option names to the values. For example:: autodoc_default_options = { From 59bc1da6aede3b1ffc6d09fc3f4c6c26ff3788e0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 22 Aug 2018 14:33:48 +0900 Subject: [PATCH 3/8] Fix html: search box overrides to other elements if scrolled --- CHANGES | 2 ++ sphinx/themes/basic/static/basic.css_t | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 7b59d857a..1d851a424 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* html: search box overrides to other elements if scrolled + Testing -------- diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index cab3a342b..94a8fa888 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -81,6 +81,10 @@ div.sphinxsidebar input { font-size: 1em; } +div.sphinxsidebar #searchbox form.search { + overflow: hidden; +} + div.sphinxsidebar #searchbox input[type="text"] { float: left; width: 80%; From bde53bf9fbdf612a48adf377c15c03a5e31113da Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 22 Aug 2018 15:28:16 +0900 Subject: [PATCH 4/8] Fix #5320: intersphinx: crashed if invalid url given --- CHANGES | 2 ++ sphinx/ext/intersphinx.py | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 5f6bbaf8d..94f7fce05 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #5320: intersphinx: crashed if invalid url given + Testing -------- diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 372f7baab..88e9997eb 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -403,14 +403,19 @@ def inspect_main(argv): def warn(self, msg): print(msg, file=sys.stderr) - filename = argv[0] - invdata = fetch_inventory(MockApp(), '', filename) # type: ignore - for key in sorted(invdata or {}): - print(key) - for entry, einfo in sorted(invdata[key].items()): - print('\t%-40s %s%s' % (entry, - einfo[3] != '-' and '%-40s: ' % einfo[3] or '', - einfo[2])) + try: + filename = argv[0] + invdata = fetch_inventory(MockApp(), '', filename) # type: ignore + for key in sorted(invdata or {}): + print(key) + for entry, einfo in sorted(invdata[key].items()): + print('\t%-40s %s%s' % (entry, + einfo[3] != '-' and '%-40s: ' % einfo[3] or '', + einfo[2])) + except ValueError as exc: + print(exc.args[0] % exc.args[1:]) + except Exception as exc: + print('Unknown error: %r' % exc) if __name__ == '__main__': From 32ba1120919ed5455c7f69a415a07c95bd25de3f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 22 Aug 2018 18:17:54 +0900 Subject: [PATCH 5/8] Fix #5325: latex: cross references has been broken by multiply labeled objects --- CHANGES | 2 ++ sphinx/writers/latex.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 7b59d857a..e4b7ebc86 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #5325: latex: cross references has been broken by multiply labeled objects + Testing -------- diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 7bd441e26..cd222f1c7 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1858,8 +1858,11 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append(self.hypertarget(id, anchor=anchor)) # skip if visitor for next node supports hyperlink + next_node = node + while isinstance(next_node, nodes.target): + next_node = next_node.next_node(ascend=True) + domain = self.builder.env.get_domain('std') - next_node = node.next_node(ascend=True) if isinstance(next_node, HYPERLINK_SUPPORT_NODES): return elif domain.get_enumerable_node_type(next_node) and domain.get_numfig_title(next_node): From 59a766d7d69d072ee5cf90455f52ff0d169b4442 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 21 Aug 2018 20:05:17 +0900 Subject: [PATCH 6/8] Fix #5322: autodoc: ``Any`` typehint causes formatting error --- CHANGES | 2 ++ sphinx/util/inspect.py | 4 +++- tests/test_util_inspect.py | 6 +++++- tests/typing_test_data.py | 6 +++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 5f6bbaf8d..798187983 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #5322: autodoc: ``Any`` typehint causes formatting error + Testing -------- diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 3b5d48e2a..bab88eb88 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -531,8 +531,10 @@ class Signature(object): qualname = annotation.__qualname__ elif getattr(annotation, '__forward_arg__', None): qualname = annotation.__forward_arg__ - else: + elif getattr(annotation, '__origin__', None): qualname = self.format_annotation(annotation.__origin__) # ex. Union + else: + qualname = repr(annotation).replace('typing.', '') elif hasattr(annotation, '__qualname__'): qualname = '%s.%s' % (module, annotation.__qualname__) else: diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py index a48aedcf0..928a45621 100644 --- a/tests/test_util_inspect.py +++ b/tests/test_util_inspect.py @@ -232,7 +232,7 @@ def test_Signature_partialmethod(): reason='type annotation test is available on py34 or above') def test_Signature_annotations(): from typing_test_data import ( - f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, Node) + f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, Node) # Class annotations sig = inspect.Signature(f0).format_args() @@ -293,6 +293,10 @@ def test_Signature_annotations(): sig = inspect.Signature(f13).format_args() assert sig == '() -> Optional[str]' + # Any + sig = inspect.Signature(f14).format_args() + assert sig == '() -> Any' + # type hints by string sig = inspect.Signature(Node.children).format_args() assert sig == '(self) -> List[typing_test_data.Node]' diff --git a/tests/typing_test_data.py b/tests/typing_test_data.py index 5b161eac4..4dc2d06f5 100644 --- a/tests/typing_test_data.py +++ b/tests/typing_test_data.py @@ -1,5 +1,5 @@ from numbers import Integral -from typing import List, TypeVar, Union, Callable, Tuple, Optional +from typing import Any, List, TypeVar, Union, Callable, Tuple, Optional def f0(x: int, y: Integral) -> None: @@ -72,6 +72,10 @@ def f13() -> Optional[str]: pass +def f14() -> Any: + pass + + class Node: def __init__(self, parent: Optional['Node']) -> None: pass From ee604144c6ad09979820647e938138ad021e62b0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 22 Aug 2018 19:48:43 +0900 Subject: [PATCH 7/8] Fix #5326: manpage: crashed when invalid docname is specified as ``man_pages`` --- CHANGES | 3 +++ sphinx/builders/manpage.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index 5f6bbaf8d..275a895ef 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,9 @@ Features added Bugs fixed ---------- +* #5326: manpage: crashed when invalid docname is specified as ``man_pages`` + + Testing -------- diff --git a/sphinx/builders/manpage.py b/sphinx/builders/manpage.py index 7a691ccf0..03462be6b 100644 --- a/sphinx/builders/manpage.py +++ b/sphinx/builders/manpage.py @@ -18,6 +18,7 @@ from six import string_types from sphinx import addnodes from sphinx.builders import Builder from sphinx.environment import NoUri +from sphinx.locale import __ from sphinx.util import logging from sphinx.util.console import bold, darkgreen # type: ignore from sphinx.util.nodes import inline_all_toctrees @@ -72,6 +73,10 @@ class ManualPageBuilder(Builder): for info in self.config.man_pages: docname, name, description, authors, section = info + if docname not in self.env.all_docs: + logger.warning(__('"man_pages" config value references unknown ' + 'document %s'), docname) + continue if isinstance(authors, string_types): if authors: authors = [authors] From 520797a5e8c52f9bdcdcf8cd85484b4c7d0ed21f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 25 Aug 2018 02:21:39 +0900 Subject: [PATCH 8/8] test: Upgrade python on Circle CI to 3.5 --- .circleci/config.yml | 6 +++--- tests/test_util_inspect.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f4d4415f1..d349db6e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,6 @@ jobs: working_directory: /sphinx steps: - checkout - - run: /python3.4/bin/pip install -U pip setuptools - - run: /python3.4/bin/pip install -U .[test,websupport] - - run: make test PYTHON=/python3.4/bin/python + - 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 diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py index 928a45621..eddca6241 100644 --- a/tests/test_util_inspect.py +++ b/tests/test_util_inspect.py @@ -299,7 +299,10 @@ def test_Signature_annotations(): # type hints by string sig = inspect.Signature(Node.children).format_args() - assert sig == '(self) -> List[typing_test_data.Node]' + if (3, 5, 0) <= sys.version_info < (3, 5, 3): + assert sig == '(self) -> List[Node]' + else: + assert sig == '(self) -> List[typing_test_data.Node]' sig = inspect.Signature(Node.__init__).format_args() assert sig == '(self, parent: Optional[Node]) -> None'