summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-01-08 20:19:36 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-01-08 20:19:36 +0900
commit326d7e64cedb5280a9cf51a90c00266e1dab9e7b (patch)
tree0ce4e7845e09aa822da027fbe6401174458c47d9 /sphinx/util
parent7a194f52960fe5ace04ef7daa72563e6d3bf094f (diff)
parent3965b1f023bbac932d0dfbf414386f0667ec002a (diff)
downloadsphinx-git-326d7e64cedb5280a9cf51a90c00266e1dab9e7b.tar.gz
Merge branch 'master' into dont_emit_system_message_on_autodoc_warning
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/__init__.py2
-rw-r--r--sphinx/util/console.py2
-rw-r--r--sphinx/util/docfields.py2
-rw-r--r--sphinx/util/docstrings.py2
-rw-r--r--sphinx/util/docutils.py26
-rw-r--r--sphinx/util/fileutil.py2
-rw-r--r--sphinx/util/i18n.py2
-rw-r--r--sphinx/util/images.py2
-rw-r--r--sphinx/util/inspect.py2
-rw-r--r--sphinx/util/inventory.py2
-rw-r--r--sphinx/util/jsdump.py2
-rw-r--r--sphinx/util/jsonimpl.py2
-rw-r--r--sphinx/util/logging.py4
-rw-r--r--sphinx/util/matching.py2
-rw-r--r--sphinx/util/nodes.py2
-rw-r--r--sphinx/util/osutil.py2
-rw-r--r--sphinx/util/parallel.py2
-rw-r--r--sphinx/util/png.py2
-rw-r--r--sphinx/util/pycompat.py2
-rw-r--r--sphinx/util/requests.py2
-rw-r--r--sphinx/util/rst.py2
-rw-r--r--sphinx/util/stemmer/__init__.py2
-rw-r--r--sphinx/util/tags.py2
-rw-r--r--sphinx/util/template.py2
-rw-r--r--sphinx/util/texescape.py2
-rw-r--r--sphinx/util/typing.py2
-rw-r--r--sphinx/util/websupport.py2
27 files changed, 50 insertions, 30 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 4b62dc5f0..938ec71db 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -5,7 +5,7 @@
Utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index 63a619f55..8069dd9c9 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -5,7 +5,7 @@
Format colored console output.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py
index 4bce071c0..2f952d7cc 100644
--- a/sphinx/util/docfields.py
+++ b/sphinx/util/docfields.py
@@ -6,7 +6,7 @@
"Doc fields" are reST field lists in object descriptions that will
be domain-specifically transformed to a more appealing presentation.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/docstrings.py b/sphinx/util/docstrings.py
index c2ef91a66..bc4b96a56 100644
--- a/sphinx/util/docstrings.py
+++ b/sphinx/util/docstrings.py
@@ -5,7 +5,7 @@
Utilities for docstring processing.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py
index 00ea5919e..bfaff758f 100644
--- a/sphinx/util/docutils.py
+++ b/sphinx/util/docutils.py
@@ -5,7 +5,7 @@
Utility functions for docutils.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
@@ -18,7 +18,7 @@ from contextlib import contextmanager
import docutils
from docutils.languages import get_language
-from docutils.statemachine import ViewList
+from docutils.statemachine import StateMachine, ViewList
from docutils.parsers.rst import directives, roles, convert_directive_function
from docutils.utils import Reporter
@@ -31,8 +31,9 @@ report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(
if False:
# For type annotation
- from typing import Any, Callable, Iterator, List, Tuple # NOQA
+ from typing import Any, Callable, Generator, Iterator, List, Tuple # NOQA
from docutils import nodes # NOQA
+ from docutils.statemachine import State # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.io import SphinxFileInput # NOQA
@@ -216,3 +217,22 @@ def directive_helper(obj, has_content=None, argument_spec=None, **option_spec):
raise ExtensionError(__('when adding directive classes, no '
'additional arguments may be given'))
return obj
+
+
+@contextmanager
+def switch_source_input(state, content):
+ # type: (State, ViewList) -> Generator
+ """Switch current source input of state temporarily."""
+ try:
+ # remember the original ``get_source_and_line()`` method
+ get_source_and_line = state.memo.reporter.get_source_and_line
+
+ # replace it by new one
+ state_machine = StateMachine([], None)
+ state_machine.input_lines = content
+ state.memo.reporter.get_source_and_line = state_machine.get_source_and_line
+
+ yield
+ finally:
+ # restore the method
+ state.memo.reporter.get_source_and_line = get_source_and_line
diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py
index fe98117d2..3fd570273 100644
--- a/sphinx/util/fileutil.py
+++ b/sphinx/util/fileutil.py
@@ -5,7 +5,7 @@
File utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/i18n.py b/sphinx/util/i18n.py
index 09b53b4a0..75a8506fa 100644
--- a/sphinx/util/i18n.py
+++ b/sphinx/util/i18n.py
@@ -5,7 +5,7 @@
Builder superclass for all builders.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import gettext
diff --git a/sphinx/util/images.py b/sphinx/util/images.py
index 1c2b4033a..46187775d 100644
--- a/sphinx/util/images.py
+++ b/sphinx/util/images.py
@@ -5,7 +5,7 @@
Image utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index da13b8af0..62cd1a7e9 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -5,7 +5,7 @@
Helpers for inspecting Python modules.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/inventory.py b/sphinx/util/inventory.py
index 40c0dc648..837188b5a 100644
--- a/sphinx/util/inventory.py
+++ b/sphinx/util/inventory.py
@@ -5,7 +5,7 @@
Inventory utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py
index 73aa2ce03..6776691cf 100644
--- a/sphinx/util/jsdump.py
+++ b/sphinx/util/jsdump.py
@@ -6,7 +6,7 @@
This module implements a simple JavaScript serializer.
Uses the basestring encode function from simplejson by Bob Ippolito.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/jsonimpl.py b/sphinx/util/jsonimpl.py
index 09c04dc6a..fbaa72978 100644
--- a/sphinx/util/jsonimpl.py
+++ b/sphinx/util/jsonimpl.py
@@ -5,7 +5,7 @@
JSON serializer implementation wrapper.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py
index 00c12ec4f..04bf91830 100644
--- a/sphinx/util/logging.py
+++ b/sphinx/util/logging.py
@@ -5,7 +5,7 @@
Logging utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
@@ -53,7 +53,7 @@ VERBOSITY_MAP.update({
COLOR_MAP = defaultdict(lambda: 'blue') # type: Dict[int, unicode]
COLOR_MAP.update({
logging.ERROR: 'darkred',
- logging.WARNING: 'darkred',
+ logging.WARNING: 'red',
logging.DEBUG: 'darkgray',
})
diff --git a/sphinx/util/matching.py b/sphinx/util/matching.py
index 401f5f002..bddf84f5c 100644
--- a/sphinx/util/matching.py
+++ b/sphinx/util/matching.py
@@ -5,7 +5,7 @@
Pattern-matching utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index cf57edb07..4ff4937b9 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -5,7 +5,7 @@
Docutils node-related utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index a8bff11c4..b38e58e5d 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -5,7 +5,7 @@
Operating system-related utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py
index 9bc3c36e1..6340e4dfc 100644
--- a/sphinx/util/parallel.py
+++ b/sphinx/util/parallel.py
@@ -5,7 +5,7 @@
Parallel building utilities.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/png.py b/sphinx/util/png.py
index cc4447e4e..d22839fbf 100644
--- a/sphinx/util/png.py
+++ b/sphinx/util/png.py
@@ -5,7 +5,7 @@
PNG image manipulation helpers.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index 7f7ee4e9b..e1a2bad9a 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -5,7 +5,7 @@
Stuff for Python version compatibility.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/requests.py b/sphinx/util/requests.py
index fb8761481..4bd4c042e 100644
--- a/sphinx/util/requests.py
+++ b/sphinx/util/requests.py
@@ -5,7 +5,7 @@
Simple requests package loader
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py
index 6977cda96..5860b0fd5 100644
--- a/sphinx/util/rst.py
+++ b/sphinx/util/rst.py
@@ -5,7 +5,7 @@
reST helper functions.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
diff --git a/sphinx/util/stemmer/__init__.py b/sphinx/util/stemmer/__init__.py
index a41373a81..a10da7370 100644
--- a/sphinx/util/stemmer/__init__.py
+++ b/sphinx/util/stemmer/__init__.py
@@ -5,7 +5,7 @@
Word stemming utilities for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/tags.py b/sphinx/util/tags.py
index 24f64bece..2c4855e91 100644
--- a/sphinx/util/tags.py
+++ b/sphinx/util/tags.py
@@ -3,7 +3,7 @@
sphinx.util.tags
~~~~~~~~~~~~~~~~
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/template.py b/sphinx/util/template.py
index 87e81d823..a78871349 100644
--- a/sphinx/util/template.py
+++ b/sphinx/util/template.py
@@ -5,7 +5,7 @@
Templates utility functions for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py
index 07f5390c4..8d37e0f60 100644
--- a/sphinx/util/texescape.py
+++ b/sphinx/util/texescape.py
@@ -5,7 +5,7 @@
TeX escaping helper.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index d30cc230a..793504b77 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -5,7 +5,7 @@
The composit types for Sphinx.
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/websupport.py b/sphinx/util/websupport.py
index 4d91cb77c..59133b9e1 100644
--- a/sphinx/util/websupport.py
+++ b/sphinx/util/websupport.py
@@ -3,7 +3,7 @@
sphinx.util.websupport
~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""