diff --git a/CHANGES b/CHANGES index 58ff7d947..82c423f8b 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,11 @@ Incompatible changes :py:meth:`.Sphinx.add_transform()` * #4827: All ``substitution_definition`` nodes are removed from doctree on reading phase +* ``docutils.conf`` on ``$HOME`` and ``/etc`` directories are ignored. Only + ``docutils.conf`` on confdir is refered. +* #789: ``:samp:`` role supports to escape curly braces with backslash +* #4811: The files under :confval:`html_static_path` are excluded from source + files. Deprecated ---------- @@ -48,6 +53,8 @@ Deprecated * ``Config.check_types()`` is deprecated * ``Config.check_unicode()`` is deprecated * ``sphinx.application.CONFIG_FILENAME`` is deprecated +* ``highlightlang`` directive is deprecated +* ``env.read_doc()`` is deprecated * ``sphinx.writers.latex.Table.caption_footnotetexts`` is deprecated * ``sphinx.writers.latex.Table.header_footnotetexts`` is deprecated * ``sphinx.writers.latex.LaTeXWriter.footnotestack`` is deprecated @@ -86,6 +93,7 @@ Features added :rst:role:`menuselection` (refs: #4830) * Add ``Config.read()`` classmethod to create a new config object from configuration file +* #4866: Wrap graphviz diagrams in ``
' + html = (r'
' r'caption of graph.*
\s*' + html = (r'
' r'on right.*
\s*graph
\n' + html = (r'Hellograph
digraph bar {\n' + r'
digraph bar {\n' r'foo -> bar\n' - r'}
' r'on right.*
\n' r'digraph foo {\n' + r'
digraph foo {\n' r'centered\n' - r'}
' + 'class="inheritance"/>
' + 'Test Foo!\xb6
') + assert re.search(pattern, content, re.M) + + +@pytest.mark.sphinx('html', testroot='ext-inheritance_diagram', + confoverrides={'graphviz_output_format': 'svg'}) +@pytest.mark.usefixtures('if_graphviz_found') +def test_inheritance_diagram_svg_html(app, status, warning): + app.builder.build_all() + + content = (app.outdir / 'index.html').text() + + pattern = ('Inheritance diagram of test.Foo
' + '' 'Test Foo!\xb6
') assert re.search(pattern, content, re.M) @@ -62,8 +82,9 @@ def test_inheritance_diagram_latex_alias(app, status, warning): content = (app.outdir / 'index.html').text() pattern = ('' + 'class="inheritance"/>
' 'Test Foo!\xb6
') assert re.search(pattern, content, re.M) diff --git a/tests/test_roles.py b/tests/test_roles.py new file mode 100644 index 000000000..13b4e194d --- /dev/null +++ b/tests/test_roles.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +""" + test_roles + ~~~~~~~~~~ + + Test sphinx.roles + + :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from docutils import nodes +from mock import Mock + +from sphinx.roles import emph_literal_role +from sphinx.testing.util import assert_node + + +def test_samp(): + # normal case + text = 'print 1+{variable}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, ("print 1+", + [nodes.emphasis, "variable"])],)) + assert msg == [] + + # two emphasis items + text = 'print {1}+{variable}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, ("print ", + [nodes.emphasis, "1"], + "+", + [nodes.emphasis, "variable"])],)) + assert msg == [] + + # empty curly brace + text = 'print 1+{}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, "print 1+{}"],)) + assert msg == [] + + # half-opened variable + text = 'print 1+{variable' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, "print 1+{variable"],)) + assert msg == [] + + # nested + text = 'print 1+{{variable}}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, ("print 1+", + [nodes.emphasis, "{variable"], + "}")],)) + assert msg == [] + + # emphasized item only + text = '{variable}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, nodes.emphasis, "variable"],)) + assert msg == [] + + # escaping + text = r'print 1+\{variable}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, "print 1+{variable}"],)) + assert msg == [] + + # escaping (2) + text = r'print 1+\{{variable}\}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, ("print 1+{", + [nodes.emphasis, "variable"], + "}")],)) + assert msg == [] + + # escape a backslash + text = r'print 1+\\{variable}' + ret, msg = emph_literal_role('samp', text, text, 0, Mock()) + assert_node(ret, ([nodes.literal, ("print 1+\\", + [nodes.emphasis, "variable"])],)) + assert msg == []