summaryrefslogtreecommitdiff
path: root/sphinx/ext/graphviz.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-04 00:47:51 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-12-04 01:14:53 +0900
commit825426c84171e1f683414a8b32c8e3da6819ccc7 (patch)
tree74c74e92bd4e9935615092f60ae882dfa24cb844 /sphinx/ext/graphviz.py
parent22ca4c2eb913b544ba01fbe10e8f4fcd2ace49a9 (diff)
downloadsphinx-git-825426c84171e1f683414a8b32c8e3da6819ccc7.tar.gz
refactor figure_wrapper() using state.inline_text()
Diffstat (limited to 'sphinx/ext/graphviz.py')
-rw-r--r--sphinx/ext/graphviz.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py
index a926bef6e..c56c7cebd 100644
--- a/sphinx/ext/graphviz.py
+++ b/sphinx/ext/graphviz.py
@@ -18,7 +18,6 @@ from subprocess import Popen, PIPE
from docutils import nodes
from docutils.parsers.rst import directives
-from docutils.statemachine import ViewList
from six import text_type
import sphinx
@@ -28,6 +27,7 @@ from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective
from sphinx.util.fileutil import copy_asset
from sphinx.util.i18n import search_image_for_language
+from sphinx.util.nodes import set_source_info
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
if False:
@@ -104,12 +104,10 @@ def figure_wrapper(directive, node, caption):
if 'align' in node:
figure_node['align'] = node.attributes.pop('align')
- parsed = nodes.Element()
- directive.state.nested_parse(ViewList([caption], source=''),
- directive.content_offset, parsed)
- caption_node = nodes.caption(parsed[0].rawsource, '', *parsed[0].children)
- caption_node.source = parsed[0].source
- caption_node.line = parsed[0].line
+ inodes, messages = directive.state.inline_text(caption, directive.lineno)
+ caption_node = nodes.caption(caption, '', *inodes)
+ caption_node.extend(messages)
+ set_source_info(directive, caption_node)
figure_node += caption_node
return figure_node