summaryrefslogtreecommitdiff
path: root/sphinx/addnodes.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-16 00:32:10 +0900
committerGitHub <noreply@github.com>2018-12-16 00:32:10 +0900
commitc70e65fc6cd04d02df4f7911025f534dbd27cc20 (patch)
tree1e8614ac5516dace99ef1df4d203081662c7c2d6 /sphinx/addnodes.py
parentd6d4406ce987cc8823d1b3a33be3a418bcd2a59d (diff)
parent79eec90f36f5a74e24cfd6740126396fd6567e07 (diff)
downloadsphinx-git-c70e65fc6cd04d02df4f7911025f534dbd27cc20.tar.gz
Merge branch 'master' into 5770_doctest_refers_highlight_language
Diffstat (limited to 'sphinx/addnodes.py')
-rw-r--r--sphinx/addnodes.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py
index d907f617a..7c8f2c9d0 100644
--- a/sphinx/addnodes.py
+++ b/sphinx/addnodes.py
@@ -13,13 +13,12 @@ import warnings
from docutils import nodes
-from sphinx.deprecation import RemovedInSphinx30Warning
+from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning
if False:
# For type annotation
from typing import Any, Dict, List, Sequence # NOQA
from sphinx.application import Sphinx # NOQA
- from sphinx.util.typing import unicode # NOQA
class translatable(nodes.Node):
@@ -42,12 +41,12 @@ class translatable(nodes.Node):
raise NotImplementedError
def apply_translated_message(self, original_message, translated_message):
- # type: (unicode, unicode) -> None
+ # type: (str, str) -> None
"""Apply translated message."""
raise NotImplementedError
def extract_original_messages(self):
- # type: () -> Sequence[unicode]
+ # type: () -> Sequence[str]
"""Extract translation messages.
:returns: list of extracted messages or messages generator
@@ -69,12 +68,12 @@ class toctree(nodes.General, nodes.Element, translatable):
self['rawcaption'] = self['caption']
def apply_translated_message(self, original_message, translated_message):
- # type: (unicode, unicode) -> None
+ # type: (str, str) -> None
if self.get('rawcaption') == original_message:
self['caption'] = translated_message
def extract_original_messages(self):
- # type: () -> List[unicode]
+ # type: () -> List[str]
if 'rawcaption' in self:
return [self['rawcaption']]
else:
@@ -128,7 +127,7 @@ class desc_type(nodes.Part, nodes.Inline, nodes.FixedTextElement):
class desc_returns(desc_type):
"""Node for a "returns" annotation (a la -> in Python)."""
def astext(self):
- # type: () -> unicode
+ # type: () -> str
return ' -> ' + super(desc_returns, self).astext()
@@ -150,7 +149,7 @@ class desc_optional(nodes.Part, nodes.Inline, nodes.FixedTextElement):
child_text_separator = ', '
def astext(self):
- # type: () -> unicode
+ # type: () -> str
return '[' + super(desc_optional, self).astext() + ']'
@@ -344,8 +343,18 @@ class literal_strong(nodes.strong, not_smartquotable):
"""
-class abbreviation(nodes.Inline, nodes.TextElement):
- """Node for abbreviations with explanations."""
+class abbreviation(nodes.abbreviation):
+ """Node for abbreviations with explanations.
+
+ .. deprecated:: 2.0
+ """
+
+ def __init__(self, rawsource='', text='', *children, **attributes):
+ # type: (str, str, *nodes.Node, **Any) -> None
+ warnings.warn("abbrevition node for Sphinx was replaced by docutils'.",
+ RemovedInSphinx40Warning, stacklevel=2)
+
+ super(abbreviation, self).__init__(rawsource, text, *children, **attributes)
class manpage(nodes.Inline, nodes.FixedTextElement):
@@ -353,7 +362,7 @@ class manpage(nodes.Inline, nodes.FixedTextElement):
def setup(app):
- # type: (Sphinx) -> Dict[unicode, Any]
+ # type: (Sphinx) -> Dict[str, Any]
app.add_node(toctree)
app.add_node(desc)
app.add_node(desc_signature)
@@ -389,7 +398,6 @@ def setup(app):
app.add_node(download_reference)
app.add_node(literal_emphasis)
app.add_node(literal_strong)
- app.add_node(abbreviation, override=True)
app.add_node(manpage)
return {