2013-07-27 14:13:15 +09:00
|
|
|
"""Test docutils.conf support for several writers."""
|
|
|
|
|
|
2024-11-22 21:54:26 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2017-01-06 01:14:47 +09:00
|
|
|
import pytest
|
2019-02-09 00:36:25 +09:00
|
|
|
from docutils import nodes
|
2018-02-19 22:39:14 +09:00
|
|
|
|
2019-02-09 00:36:25 +09:00
|
|
|
from sphinx.testing.util import assert_node
|
2018-03-29 22:45:20 +09:00
|
|
|
from sphinx.util.docutils import patch_docutils
|
2013-07-27 14:13:15 +09:00
|
|
|
|
|
|
|
|
|
2024-08-11 14:58:56 +01:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
|
'dummy',
|
|
|
|
|
testroot='docutilsconf',
|
|
|
|
|
freshenv=True,
|
|
|
|
|
)
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_html_with_default_docutilsconf(app):
|
2018-03-29 22:45:20 +09:00
|
|
|
with patch_docutils(app.confdir):
|
2019-02-09 00:36:25 +09:00
|
|
|
app.build()
|
2018-03-29 22:45:20 +09:00
|
|
|
|
2019-02-09 00:36:25 +09:00
|
|
|
doctree = app.env.get_doctree('index')
|
2024-08-11 14:58:56 +01:00
|
|
|
assert_node(
|
|
|
|
|
doctree[0][1], [nodes.paragraph, ('Sphinx ', [nodes.footnote_reference, '1'])]
|
|
|
|
|
)
|
2013-07-27 14:13:15 +09:00
|
|
|
|
|
|
|
|
|
2024-08-11 14:58:56 +01:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
|
'dummy',
|
|
|
|
|
testroot='docutilsconf',
|
|
|
|
|
freshenv=True,
|
|
|
|
|
docutils_conf='[restructuredtext parser]\ntrim_footnote_reference_space: true\n',
|
|
|
|
|
)
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_html_with_docutilsconf(app):
|
2018-03-29 22:45:20 +09:00
|
|
|
with patch_docutils(app.confdir):
|
2019-02-09 00:36:25 +09:00
|
|
|
app.build()
|
2013-07-27 14:13:15 +09:00
|
|
|
|
2019-02-09 00:36:25 +09:00
|
|
|
doctree = app.env.get_doctree('index')
|
2024-08-11 14:58:56 +01:00
|
|
|
assert_node(
|
|
|
|
|
doctree[0][1], [nodes.paragraph, ('Sphinx', [nodes.footnote_reference, '1'])]
|
|
|
|
|
)
|