2022-02-19 21:05:56 -06:00
|
|
|
"""Test various Sphinx-specific markup extensions."""
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
|
2018-02-19 07:39:14 -06:00
|
|
|
import re
|
2022-04-21 20:53:25 -05:00
|
|
|
import warnings
|
2023-07-28 17:24:13 -05:00
|
|
|
from types import SimpleNamespace
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2018-02-19 07:39:14 -06:00
|
|
|
import pytest
|
2020-11-11 05:00:27 -06:00
|
|
|
from docutils import frontend, nodes, utils
|
2017-01-06 09:46:26 -06:00
|
|
|
from docutils.parsers.rst import Parser as RstParser
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
|
2016-09-10 09:31:43 -05:00
|
|
|
from sphinx import addnodes
|
2020-04-30 07:48:53 -05:00
|
|
|
from sphinx.builders.html.transforms import KeyboardTransform
|
2018-08-07 11:19:33 -05:00
|
|
|
from sphinx.builders.latex import LaTeXBuilder
|
2022-03-19 02:44:23 -05:00
|
|
|
from sphinx.environment import default_settings
|
2019-02-16 00:23:07 -06:00
|
|
|
from sphinx.roles import XRefRole
|
2023-07-28 17:24:13 -05:00
|
|
|
from sphinx.testing.util import assert_node
|
2020-05-01 10:09:55 -05:00
|
|
|
from sphinx.transforms import SphinxSmartQuotes
|
2022-04-21 21:10:43 -05:00
|
|
|
from sphinx.util import texescape
|
2016-09-08 23:37:00 -05:00
|
|
|
from sphinx.util.docutils import sphinx_domains
|
2024-07-23 16:19:15 -05:00
|
|
|
from sphinx.writers.html import HTMLWriter
|
|
|
|
from sphinx.writers.html5 import HTML5Translator
|
2020-11-11 05:00:27 -06:00
|
|
|
from sphinx.writers.latex import LaTeXTranslator, LaTeXWriter
|
2013-04-01 04:39:32 -05:00
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def settings(app):
|
2009-01-03 05:29:42 -06:00
|
|
|
texescape.init() # otherwise done by the latex builder
|
2022-04-21 20:53:25 -05:00
|
|
|
with warnings.catch_warnings():
|
|
|
|
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
|
|
|
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
|
|
|
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
|
|
|
optparser = frontend.OptionParser(
|
2024-10-05 12:11:47 -05:00
|
|
|
components=(RstParser, HTMLWriter, LaTeXWriter),
|
2024-10-04 09:41:25 -05:00
|
|
|
defaults=default_settings,
|
2024-08-11 08:58:56 -05:00
|
|
|
)
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
settings = optparser.get_default_values()
|
2017-03-14 15:43:04 -05:00
|
|
|
settings.smart_quotes = True
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
settings.env = app.builder.env
|
2010-01-17 17:41:34 -06:00
|
|
|
settings.env.temp_data['docname'] = 'dummy'
|
2018-11-27 10:53:00 -06:00
|
|
|
settings.contentsname = 'dummy'
|
2016-09-08 23:37:00 -05:00
|
|
|
domain_context = sphinx_domains(settings.env)
|
|
|
|
domain_context.enable()
|
2017-01-06 09:46:26 -06:00
|
|
|
yield settings
|
|
|
|
domain_context.disable()
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2019-02-16 00:23:07 -06:00
|
|
|
def new_document(settings):
|
|
|
|
def create():
|
|
|
|
document = utils.new_document('test data', settings)
|
2017-01-06 09:46:26 -06:00
|
|
|
document['file'] = 'dummy'
|
2019-02-16 00:23:07 -06:00
|
|
|
return document
|
|
|
|
|
|
|
|
return create
|
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2019-02-16 00:23:07 -06:00
|
|
|
def inliner(new_document):
|
|
|
|
document = new_document()
|
|
|
|
document.reporter.get_source_and_line = lambda line=1: ('dummy.rst', line)
|
2023-07-28 17:24:13 -05:00
|
|
|
return SimpleNamespace(document=document, reporter=document.reporter)
|
2019-02-16 00:23:07 -06:00
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2019-02-16 00:23:07 -06:00
|
|
|
def parse(new_document):
|
|
|
|
def parse_(rst):
|
|
|
|
document = new_document()
|
2017-01-06 09:46:26 -06:00
|
|
|
parser = RstParser()
|
|
|
|
parser.parse(rst, document)
|
2024-07-23 16:19:15 -05:00
|
|
|
SphinxSmartQuotes(document, startnode=None).apply() # type: ignore[no-untyped-call]
|
2022-01-02 10:05:46 -06:00
|
|
|
for msg in list(document.findall(nodes.system_message)):
|
2017-01-06 09:46:26 -06:00
|
|
|
if msg['level'] == 1:
|
|
|
|
msg.replace_self([])
|
|
|
|
return document
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return parse_
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
|
2016-06-11 10:00:52 -05:00
|
|
|
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
# since we're not resolving the markup afterwards, these nodes may remain
|
|
|
|
class ForgivingTranslator:
|
|
|
|
def visit_pending_xref(self, node):
|
|
|
|
pass
|
2014-09-21 10:17:02 -05:00
|
|
|
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
def depart_pending_xref(self, node):
|
|
|
|
pass
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2022-12-29 18:53:04 -06:00
|
|
|
class ForgivingHTMLTranslator(HTML5Translator, ForgivingTranslator):
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
pass
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
class ForgivingLaTeXTranslator(LaTeXTranslator, ForgivingTranslator):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def verify_re_html(app, parse):
|
|
|
|
def verify(rst, html_expected):
|
|
|
|
document = parse(rst)
|
2020-04-30 07:48:53 -05:00
|
|
|
KeyboardTransform(document).apply()
|
2019-01-02 22:27:33 -06:00
|
|
|
html_translator = ForgivingHTMLTranslator(document, app.builder)
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
document.walkabout(html_translator)
|
|
|
|
html_translated = ''.join(html_translator.fragment).strip()
|
2009-09-12 05:14:27 -05:00
|
|
|
assert re.match(html_expected, html_translated), 'from ' + rst
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify
|
|
|
|
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def verify_re_latex(app, parse):
|
|
|
|
def verify(rst, latex_expected):
|
|
|
|
document = parse(rst)
|
2022-06-16 13:50:01 -05:00
|
|
|
app.builder = LaTeXBuilder(app, app.env)
|
2019-01-07 10:30:15 -06:00
|
|
|
app.builder.init()
|
2020-05-03 09:56:59 -05:00
|
|
|
theme = app.builder.themes.get('manual')
|
|
|
|
latex_translator = ForgivingLaTeXTranslator(document, app.builder, theme)
|
2016-06-11 10:00:52 -05:00
|
|
|
latex_translator.first_document = -1 # don't write \begin{document}
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
document.walkabout(latex_translator)
|
|
|
|
latex_translated = ''.join(latex_translator.body).strip()
|
2008-08-10 11:59:27 -05:00
|
|
|
assert re.match(latex_expected, latex_translated), 'from ' + repr(rst)
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify
|
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def verify_re(verify_re_html, verify_re_latex):
|
|
|
|
def verify_re_(rst, html_expected, latex_expected):
|
|
|
|
if html_expected:
|
2017-03-14 12:30:58 -05:00
|
|
|
verify_re_html(rst, html_expected)
|
2017-01-06 09:46:26 -06:00
|
|
|
if latex_expected:
|
2017-03-14 12:30:58 -05:00
|
|
|
verify_re_latex(rst, latex_expected)
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify_re_
|
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def verify(verify_re_html, verify_re_latex):
|
|
|
|
def verify_(rst, html_expected, latex_expected):
|
|
|
|
if html_expected:
|
2017-03-14 12:30:58 -05:00
|
|
|
verify_re_html(rst, re.escape(html_expected) + '$')
|
2017-01-06 09:46:26 -06:00
|
|
|
if latex_expected:
|
2017-03-14 12:30:58 -05:00
|
|
|
verify_re_latex(rst, re.escape(latex_expected) + '$')
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify_
|
|
|
|
|
|
|
|
|
2024-07-10 08:13:10 -05:00
|
|
|
@pytest.fixture
|
2017-01-06 09:46:26 -06:00
|
|
|
def get_verifier(verify, verify_re):
|
|
|
|
v = {
|
|
|
|
'verify': verify,
|
|
|
|
'verify_re': verify_re,
|
|
|
|
}
|
2017-01-25 10:13:17 -06:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
def get(name):
|
|
|
|
return v[name]
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
return get
|
|
|
|
|
|
|
|
|
2024-08-11 08:58:56 -05:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
('type', 'rst', 'html_expected', 'latex_expected'),
|
|
|
|
[
|
2024-10-05 12:44:14 -05:00
|
|
|
(
|
|
|
|
# cve role
|
|
|
|
'verify',
|
|
|
|
':cve:`2020-10735`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="cve reference external" '
|
|
|
|
'href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735">'
|
|
|
|
'<strong>CVE 2020-10735</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Common Vulnerabilities and Exposures@\\spxentry{Common Vulnerabilities and Exposures}'
|
|
|
|
'!CVE 2020\\sphinxhyphen{}10735@\\spxentry{CVE 2020\\sphinxhyphen{}10735}}'
|
|
|
|
'\\sphinxhref{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735}'
|
|
|
|
'{\\sphinxstylestrong{CVE 2020\\sphinxhyphen{}10735}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# cve role with anchor
|
|
|
|
'verify',
|
|
|
|
':cve:`2020-10735#id1`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="cve reference external" '
|
|
|
|
'href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735#id1">'
|
|
|
|
'<strong>CVE 2020-10735#id1</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Common Vulnerabilities and Exposures@\\spxentry{Common Vulnerabilities and Exposures}'
|
|
|
|
'!CVE 2020\\sphinxhyphen{}10735\\#id1@\\spxentry{CVE 2020\\sphinxhyphen{}10735\\#id1}}'
|
|
|
|
'\\sphinxhref{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735\\#id1}'
|
|
|
|
'{\\sphinxstylestrong{CVE 2020\\sphinxhyphen{}10735\\#id1}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# cwe role
|
|
|
|
'verify',
|
|
|
|
':cwe:`787`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="cwe reference external" '
|
|
|
|
'href="https://cwe.mitre.org/data/definitions/787.html">'
|
|
|
|
'<strong>CWE 787</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Common Weakness Enumeration@\\spxentry{Common Weakness Enumeration}'
|
|
|
|
'!CWE 787@\\spxentry{CWE 787}}'
|
|
|
|
'\\sphinxhref{https://cwe.mitre.org/data/definitions/787.html}'
|
|
|
|
'{\\sphinxstylestrong{CWE 787}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# cwe role with anchor
|
|
|
|
'verify',
|
|
|
|
':cwe:`787#id1`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="cwe reference external" '
|
|
|
|
'href="https://cwe.mitre.org/data/definitions/787.html#id1">'
|
|
|
|
'<strong>CWE 787#id1</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Common Weakness Enumeration@\\spxentry{Common Weakness Enumeration}'
|
|
|
|
'!CWE 787\\#id1@\\spxentry{CWE 787\\#id1}}'
|
|
|
|
'\\sphinxhref{https://cwe.mitre.org/data/definitions/787.html\\#id1}'
|
|
|
|
'{\\sphinxstylestrong{CWE 787\\#id1}}'
|
|
|
|
),
|
|
|
|
),
|
2024-08-11 08:58:56 -05:00
|
|
|
(
|
|
|
|
# pep role
|
|
|
|
'verify',
|
|
|
|
':pep:`8`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="pep reference external" '
|
|
|
|
'href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
|
|
|
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
|
|
|
|
'{\\sphinxstylestrong{PEP 8}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# pep role with anchor
|
|
|
|
'verify',
|
|
|
|
':pep:`8#id1`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="pep reference external" '
|
|
|
|
'href="https://peps.python.org/pep-0008/#id1">'
|
|
|
|
'<strong>PEP 8#id1</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
|
|
|
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
|
|
|
|
'{https://peps.python.org/pep-0008/\\#id1}'
|
|
|
|
'{\\sphinxstylestrong{PEP 8\\#id1}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# rfc role
|
|
|
|
'verify',
|
|
|
|
':rfc:`2324`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="rfc reference external" '
|
|
|
|
'href="https://datatracker.ietf.org/doc/html/rfc2324.html"><strong>RFC 2324</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}'
|
|
|
|
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html}'
|
|
|
|
'{\\sphinxstylestrong{RFC 2324}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# rfc role with anchor
|
|
|
|
'verify',
|
|
|
|
':rfc:`2324#id1`',
|
|
|
|
(
|
|
|
|
'<p><span class="target" id="index-0"></span><a class="rfc reference external" '
|
|
|
|
'href="https://datatracker.ietf.org/doc/html/rfc2324.html#id1">'
|
|
|
|
'<strong>RFC 2324#id1</strong></a></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}'
|
|
|
|
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html\\#id1}'
|
|
|
|
'{\\sphinxstylestrong{RFC 2324\\#id1}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# correct interpretation of code with whitespace
|
|
|
|
'verify_re',
|
|
|
|
'``code sample``',
|
|
|
|
(
|
|
|
|
'<p><code class="(samp )?docutils literal notranslate"><span class="pre">'
|
|
|
|
'code</span>   <span class="pre">sample</span></code></p>'
|
|
|
|
),
|
|
|
|
r'\\sphinxAtStartPar\n\\sphinxcode{\\sphinxupquote{code sample}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of arrows in menuselection
|
|
|
|
'verify',
|
|
|
|
':menuselection:`a --> b`',
|
|
|
|
'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxmenuselection{a \\(\\rightarrow\\) b}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of ampersands in menuselection
|
|
|
|
'verify',
|
|
|
|
':menuselection:`&Foo -&&- &Bar`',
|
|
|
|
(
|
|
|
|
'<p><span class="menuselection"><span class="accelerator">F</span>oo '
|
|
|
|
'-&- <span class="accelerator">B</span>ar</span></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
r'\sphinxmenuselection{\sphinxaccelerator{F}oo \sphinxhyphen{}'
|
|
|
|
r'\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of ampersands in guilabel
|
|
|
|
'verify',
|
|
|
|
':guilabel:`&Foo -&&- &Bar`',
|
|
|
|
(
|
|
|
|
'<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
|
|
|
'-&- <span class="accelerator">B</span>ar</span></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
r'\sphinxguilabel{\sphinxaccelerator{F}oo \sphinxhyphen{}\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# no ampersands in guilabel
|
|
|
|
'verify',
|
|
|
|
':guilabel:`Foo`',
|
|
|
|
'<p><span class="guilabel">Foo</span></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxguilabel{Foo}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`space`',
|
|
|
|
'<p><kbd class="kbd docutils literal notranslate">space</kbd></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{space}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`Control+X`',
|
|
|
|
(
|
|
|
|
'<p><kbd class="kbd compound docutils literal notranslate">'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">Control</kbd>'
|
|
|
|
'+'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">X</kbd>'
|
|
|
|
'</kbd></p>'
|
|
|
|
),
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{Control+X}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`Alt+^`',
|
|
|
|
(
|
|
|
|
'<p><kbd class="kbd compound docutils literal notranslate">'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">Alt</kbd>'
|
|
|
|
'+'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">^</kbd>'
|
|
|
|
'</kbd></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\sphinxkeyboard{\\sphinxupquote{Alt+\\textasciicircum{}}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`M-x M-s`',
|
|
|
|
(
|
|
|
|
'<p><kbd class="kbd compound docutils literal notranslate">'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">M</kbd>'
|
|
|
|
'-'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">x</kbd>'
|
|
|
|
' '
|
|
|
|
'<kbd class="kbd docutils literal notranslate">M</kbd>'
|
|
|
|
'-'
|
|
|
|
'<kbd class="kbd docutils literal notranslate">s</kbd>'
|
|
|
|
'</kbd></p>'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\sphinxkeyboard{\\sphinxupquote{M\\sphinxhyphen{}x M\\sphinxhyphen{}s}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`-`',
|
|
|
|
'<p><kbd class="kbd docutils literal notranslate">-</kbd></p>',
|
|
|
|
(
|
|
|
|
'\\sphinxAtStartPar\n'
|
|
|
|
'\\sphinxkeyboard{\\sphinxupquote{\\sphinxhyphen{}}}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`Caps Lock`',
|
|
|
|
'<p><kbd class="kbd docutils literal notranslate">Caps Lock</kbd></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{Caps Lock}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# kbd role
|
|
|
|
'verify',
|
|
|
|
':kbd:`sys rq`',
|
|
|
|
'<p><kbd class="kbd docutils literal notranslate">sys rq</kbd></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{sys rq}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# non-interpolation of dashes in option role
|
|
|
|
'verify_re',
|
|
|
|
':option:`--with-option`',
|
|
|
|
(
|
|
|
|
'<p><code( class="xref std std-option docutils literal notranslate")?>'
|
|
|
|
'<span class="pre">--with-option</span></code></p>$'
|
|
|
|
),
|
|
|
|
(
|
|
|
|
r'\\sphinxAtStartPar\n'
|
|
|
|
r'\\sphinxcode{\\sphinxupquote{\\sphinxhyphen{}\\sphinxhyphen{}with\\sphinxhyphen{}option}}$'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# verify smarty-pants quotes
|
|
|
|
'verify',
|
|
|
|
'"John"',
|
|
|
|
'<p>“John”</p>',
|
|
|
|
'\\sphinxAtStartPar\n“John”',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# ... but not in literal text
|
|
|
|
'verify',
|
|
|
|
'``"John"``',
|
|
|
|
(
|
|
|
|
'<p><code class="docutils literal notranslate"><span class="pre">'
|
|
|
|
'"John"</span></code></p>'
|
|
|
|
),
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxcode{\\sphinxupquote{"John"}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# verify classes for inline roles
|
|
|
|
'verify',
|
|
|
|
':manpage:`mp(1)`',
|
|
|
|
'<p><em class="manpage">mp(1)</em></p>',
|
|
|
|
'\\sphinxAtStartPar\n\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# correct escaping in normal mode
|
|
|
|
'verify',
|
|
|
|
'Γ\\\\∞$',
|
|
|
|
None,
|
|
|
|
'\\sphinxAtStartPar\nΓ\\textbackslash{}\\(\\infty\\)\\$',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# in verbatim code fragments
|
|
|
|
'verify',
|
|
|
|
'::\n\n @Γ\\∞${}',
|
|
|
|
None,
|
|
|
|
(
|
|
|
|
'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
|
|
|
|
'@Γ\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
|
|
|
|
'\\end{sphinxVerbatim}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# in URIs
|
|
|
|
'verify_re',
|
|
|
|
'`test <https://www.google.com/~me/>`_',
|
|
|
|
None,
|
|
|
|
r'\\sphinxAtStartPar\n\\sphinxhref{https://www.google.com/~me/}{test}.*',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# description list: simple
|
|
|
|
'verify',
|
|
|
|
'term\n description',
|
|
|
|
'<dl class="simple">\n<dt>term</dt><dd><p>description</p>\n</dd>\n</dl>',
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# description list: with classifiers
|
|
|
|
'verify',
|
|
|
|
'term : class1 : class2\n description',
|
|
|
|
(
|
|
|
|
'<dl class="simple">\n<dt>term<span class="classifier">class1</span>'
|
|
|
|
'<span class="classifier">class2</span></dt><dd><p>description</p>\n</dd>\n</dl>'
|
|
|
|
),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# glossary (description list): multiple terms
|
|
|
|
'verify',
|
|
|
|
'.. glossary::\n\n term1\n term2\n description',
|
|
|
|
(
|
|
|
|
'<dl class="simple glossary">\n'
|
|
|
|
'<dt id="term-term1">term1<a class="headerlink" href="#term-term1"'
|
|
|
|
' title="Link to this term">¶</a></dt>'
|
|
|
|
'<dt id="term-term2">term2<a class="headerlink" href="#term-term2"'
|
|
|
|
' title="Link to this term">¶</a></dt>'
|
|
|
|
'<dd><p>description</p>\n</dd>\n</dl>'
|
|
|
|
),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root')
|
2017-01-06 09:46:26 -06:00
|
|
|
def test_inline(get_verifier, type, rst, html_expected, latex_expected):
|
|
|
|
verifier = get_verifier(type)
|
|
|
|
verifier(rst, html_expected, latex_expected)
|
2016-05-24 22:06:49 -05:00
|
|
|
|
|
|
|
|
2024-08-11 08:58:56 -05:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
('type', 'rst', 'html_expected', 'latex_expected'),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
'verify',
|
|
|
|
r'4 backslashes \\\\',
|
|
|
|
r'<p>4 backslashes \\</p>',
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root')
|
2020-05-01 10:09:55 -05:00
|
|
|
def test_inline_docutils16(get_verifier, type, rst, html_expected, latex_expected):
|
|
|
|
verifier = get_verifier(type)
|
|
|
|
verifier(rst, html_expected, latex_expected)
|
|
|
|
|
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root', confoverrides={'latex_engine': 'xelatex'})
|
2024-08-11 08:58:56 -05:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
('type', 'rst', 'html_expected', 'latex_expected'),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
# in verbatim code fragments
|
|
|
|
'verify',
|
|
|
|
'::\n\n @Γ\\∞${}',
|
|
|
|
None,
|
|
|
|
(
|
|
|
|
'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
|
|
|
|
'@Γ\\PYGZbs{}∞\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
|
|
|
|
'\\end{sphinxVerbatim}'
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_inline_for_unicode_latex_engine(
|
|
|
|
get_verifier, type, rst, html_expected, latex_expected
|
|
|
|
):
|
2019-11-16 01:29:14 -06:00
|
|
|
verifier = get_verifier(type)
|
|
|
|
verifier(rst, html_expected, latex_expected)
|
|
|
|
|
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root')
|
2019-02-14 07:53:10 -06:00
|
|
|
def test_samp_role(parse):
|
|
|
|
# no braces
|
|
|
|
text = ':samp:`a{b}c`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctree[0], [nodes.paragraph, nodes.literal, ('a', [nodes.emphasis, 'b'], 'c')]
|
|
|
|
)
|
2019-02-14 07:53:10 -06:00
|
|
|
# nested braces
|
|
|
|
text = ':samp:`a{{b}}c`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctree[0],
|
|
|
|
[nodes.paragraph, nodes.literal, ('a', [nodes.emphasis, '{b'], '}c')],
|
|
|
|
)
|
2019-02-14 07:53:10 -06:00
|
|
|
|
|
|
|
# half-opened braces
|
|
|
|
text = ':samp:`a{bc`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0], [nodes.paragraph, nodes.literal, 'a{bc'])
|
2019-02-14 07:53:10 -06:00
|
|
|
|
|
|
|
# escaped braces
|
|
|
|
text = ':samp:`a\\\\{b}c`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0], [nodes.paragraph, nodes.literal, 'a{b}c'])
|
2019-02-14 07:53:10 -06:00
|
|
|
|
|
|
|
# no braces (whitespaces are keeped as is)
|
|
|
|
text = ':samp:`code sample`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0], [nodes.paragraph, nodes.literal, 'code sample'])
|
2019-02-14 07:53:10 -06:00
|
|
|
|
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root')
|
2019-02-16 00:22:48 -06:00
|
|
|
def test_download_role(parse):
|
|
|
|
# implicit
|
|
|
|
text = ':download:`sphinx.rst`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctree[0],
|
|
|
|
[nodes.paragraph, addnodes.download_reference, nodes.literal, 'sphinx.rst'],
|
|
|
|
)
|
|
|
|
assert_node(
|
|
|
|
doctree[0][0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='download',
|
|
|
|
refexplicit=False,
|
|
|
|
reftarget='sphinx.rst',
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:22:48 -06:00
|
|
|
assert_node(doctree[0][0][0], classes=['xref', 'download'])
|
|
|
|
|
|
|
|
# explicit
|
|
|
|
text = ':download:`reftitle <sphinx.rst>`'
|
|
|
|
doctree = parse(text)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctree[0],
|
|
|
|
[nodes.paragraph, addnodes.download_reference, nodes.literal, 'reftitle'],
|
|
|
|
)
|
|
|
|
assert_node(
|
|
|
|
doctree[0][0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='download',
|
|
|
|
refexplicit=True,
|
|
|
|
reftarget='sphinx.rst',
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:22:48 -06:00
|
|
|
assert_node(doctree[0][0][0], classes=['xref', 'download'])
|
|
|
|
|
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('html', testroot='root')
|
2019-02-16 00:23:07 -06:00
|
|
|
def test_XRefRole(inliner):
|
|
|
|
role = XRefRole()
|
|
|
|
|
|
|
|
# implicit
|
|
|
|
doctrees, errors = role('ref', 'rawtext', 'text', 5, inliner, {}, [])
|
|
|
|
assert len(doctrees) == 1
|
|
|
|
assert_node(doctrees[0], [addnodes.pending_xref, nodes.literal, 'text'])
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctrees[0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='ref',
|
|
|
|
reftarget='text',
|
|
|
|
refexplicit=False,
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:23:07 -06:00
|
|
|
assert errors == []
|
|
|
|
|
|
|
|
# explicit
|
|
|
|
doctrees, errors = role('ref', 'rawtext', 'title <target>', 5, inliner, {}, [])
|
|
|
|
assert_node(doctrees[0], [addnodes.pending_xref, nodes.literal, 'title'])
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctrees[0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='ref',
|
|
|
|
reftarget='target',
|
|
|
|
refexplicit=True,
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:23:07 -06:00
|
|
|
|
|
|
|
# bang
|
|
|
|
doctrees, errors = role('ref', 'rawtext', '!title <target>', 5, inliner, {}, [])
|
|
|
|
assert_node(doctrees[0], [nodes.literal, 'title <target>'])
|
|
|
|
|
|
|
|
# refdomain
|
|
|
|
doctrees, errors = role('test:doc', 'rawtext', 'text', 5, inliner, {}, [])
|
|
|
|
assert_node(doctrees[0], [addnodes.pending_xref, nodes.literal, 'text'])
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctrees[0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='test',
|
|
|
|
reftype='doc',
|
|
|
|
reftarget='text',
|
|
|
|
refexplicit=False,
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:23:07 -06:00
|
|
|
|
|
|
|
# fix_parens
|
|
|
|
role = XRefRole(fix_parens=True)
|
|
|
|
doctrees, errors = role('ref', 'rawtext', 'text()', 5, inliner, {}, [])
|
|
|
|
assert_node(doctrees[0], [addnodes.pending_xref, nodes.literal, 'text()'])
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctrees[0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='ref',
|
|
|
|
reftarget='text',
|
|
|
|
refexplicit=False,
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:23:07 -06:00
|
|
|
|
|
|
|
# lowercase
|
|
|
|
role = XRefRole(lowercase=True)
|
|
|
|
doctrees, errors = role('ref', 'rawtext', 'TEXT', 5, inliner, {}, [])
|
|
|
|
assert_node(doctrees[0], [addnodes.pending_xref, nodes.literal, 'TEXT'])
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(
|
|
|
|
doctrees[0],
|
|
|
|
refdoc='dummy',
|
|
|
|
refdomain='',
|
|
|
|
reftype='ref',
|
|
|
|
reftarget='text',
|
|
|
|
refexplicit=False,
|
|
|
|
refwarn=False,
|
|
|
|
)
|
2019-02-16 00:23:07 -06:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='prolog')
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_rst_prolog(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2019-02-17 04:52:08 -06:00
|
|
|
rst = app.env.get_doctree('restructuredtext')
|
|
|
|
md = app.env.get_doctree('markdown')
|
2016-05-24 22:06:49 -05:00
|
|
|
|
|
|
|
# rst_prolog
|
2016-05-25 05:58:15 -05:00
|
|
|
assert_node(rst[0], nodes.paragraph)
|
|
|
|
assert_node(rst[0][0], nodes.emphasis)
|
|
|
|
assert_node(rst[0][0][0], nodes.Text)
|
|
|
|
assert rst[0][0][0] == 'Hello world'
|
2016-05-24 22:06:49 -05:00
|
|
|
|
|
|
|
# rst_epilog
|
2016-05-25 05:58:15 -05:00
|
|
|
assert_node(rst[-1], nodes.section)
|
|
|
|
assert_node(rst[-1][-1], nodes.paragraph)
|
|
|
|
assert_node(rst[-1][-1][0], nodes.emphasis)
|
|
|
|
assert_node(rst[-1][-1][0][0], nodes.Text)
|
|
|
|
assert rst[-1][-1][0][0] == 'Good-bye world'
|
|
|
|
|
|
|
|
# rst_prolog & rst_epilog on exlucding reST parser
|
|
|
|
assert not md.rawsource.startswith('*Hello world*.')
|
|
|
|
assert not md.rawsource.endswith('*Good-bye world*.\n')
|
2016-09-10 03:38:10 -05:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='keep_warnings')
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_keep_warnings_is_True(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('index')
|
2016-09-10 03:38:10 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert len(doctree[0]) == 2
|
|
|
|
assert_node(doctree[0][1], nodes.system_message)
|
|
|
|
|
|
|
|
|
2024-08-11 08:58:56 -05:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'dummy',
|
|
|
|
testroot='keep_warnings',
|
|
|
|
confoverrides={'keep_warnings': False},
|
|
|
|
)
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_keep_warnings_is_False(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('index')
|
2016-09-10 03:38:10 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert len(doctree[0]) == 1
|
2016-09-10 09:31:43 -05:00
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='refonly_bullet_list')
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_compact_refonly_bullet_list(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('index')
|
2016-09-10 09:31:43 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert len(doctree[0]) == 5
|
|
|
|
|
|
|
|
assert doctree[0][1].astext() == 'List A:'
|
|
|
|
assert_node(doctree[0][2], nodes.bullet_list)
|
|
|
|
assert_node(doctree[0][2][0][0], addnodes.compact_paragraph)
|
|
|
|
assert doctree[0][2][0][0].astext() == 'genindex'
|
|
|
|
|
|
|
|
assert doctree[0][3].astext() == 'List B:'
|
|
|
|
assert_node(doctree[0][4], nodes.bullet_list)
|
|
|
|
assert_node(doctree[0][4][0][0], nodes.paragraph)
|
|
|
|
assert doctree[0][4][0][0].astext() == 'Hello'
|
2017-07-30 10:46:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('dummy', testroot='default_role')
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_default_role1(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2017-07-30 10:46:26 -05:00
|
|
|
|
|
|
|
# default-role: pep
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('index')
|
2017-07-30 10:46:26 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert_node(doctree[0][1], nodes.paragraph)
|
|
|
|
assert_node(doctree[0][1][0], addnodes.index)
|
|
|
|
assert_node(doctree[0][1][1], nodes.target)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0][1][2], nodes.reference, classes=['pep'])
|
2017-07-30 10:46:26 -05:00
|
|
|
|
|
|
|
# no default-role
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('foo')
|
2017-07-30 10:46:26 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert_node(doctree[0][1], nodes.paragraph)
|
|
|
|
assert_node(doctree[0][1][0], nodes.title_reference)
|
|
|
|
assert_node(doctree[0][1][1], nodes.Text)
|
|
|
|
|
|
|
|
|
2024-08-11 08:58:56 -05:00
|
|
|
@pytest.mark.sphinx(
|
|
|
|
'dummy',
|
|
|
|
testroot='default_role',
|
|
|
|
confoverrides={'default_role': 'guilabel'},
|
|
|
|
)
|
2024-07-23 09:35:55 -05:00
|
|
|
def test_default_role2(app):
|
2024-01-16 20:38:46 -06:00
|
|
|
app.build(force_all=True)
|
2017-07-30 10:46:26 -05:00
|
|
|
|
|
|
|
# default-role directive is stronger than configratuion
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('index')
|
2017-07-30 10:46:26 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert_node(doctree[0][1], nodes.paragraph)
|
|
|
|
assert_node(doctree[0][1][0], addnodes.index)
|
|
|
|
assert_node(doctree[0][1][1], nodes.target)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0][1][2], nodes.reference, classes=['pep'])
|
2017-07-30 10:46:26 -05:00
|
|
|
|
|
|
|
# default_role changes the default behavior
|
2019-02-17 04:52:08 -06:00
|
|
|
doctree = app.env.get_doctree('foo')
|
2017-07-30 10:46:26 -05:00
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert_node(doctree[0][1], nodes.paragraph)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert_node(doctree[0][1][0], nodes.inline, classes=['guilabel'])
|
2017-07-30 10:46:26 -05:00
|
|
|
assert_node(doctree[0][1][1], nodes.Text)
|