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
|
|
|
"""
|
|
|
|
test_markup
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test various Sphinx-specific markup extensions.
|
|
|
|
|
2019-01-02 01:00:30 -06:00
|
|
|
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
2008-12-27 05:19:17 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
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-05-24 22:06:49 -05:00
|
|
|
import pickle
|
2018-02-19 07:39:14 -06:00
|
|
|
import re
|
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
|
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
|
|
|
from docutils import frontend, utils, nodes
|
2017-01-06 09:46:26 -06:00
|
|
|
from docutils.parsers.rst import Parser as RstParser
|
2017-03-14 15:43:04 -05:00
|
|
|
from docutils.transforms.universal import SmartQuotes
|
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
|
2018-08-07 11:19:33 -05:00
|
|
|
from sphinx.builders.latex import LaTeXBuilder
|
2018-02-19 07:39:14 -06:00
|
|
|
from sphinx.testing.util import assert_node
|
2009-01-03 05:29:42 -06:00
|
|
|
from sphinx.util import texescape
|
2016-09-08 23:37:00 -05:00
|
|
|
from sphinx.util.docutils import sphinx_domains
|
2017-03-14 15:43:04 -05:00
|
|
|
from sphinx.writers.html import HTMLWriter, HTMLTranslator
|
2008-11-29 12:56:58 -06:00
|
|
|
from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator
|
2013-04-01 04:39:32 -05:00
|
|
|
|
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
@pytest.fixture
|
|
|
|
def settings(app):
|
2009-01-03 05:29:42 -06:00
|
|
|
texescape.init() # otherwise done by the latex builder
|
2009-01-10 15:18:18 -06:00
|
|
|
optparser = frontend.OptionParser(
|
2017-01-06 09:46:26 -06:00
|
|
|
components=(RstParser, HTMLWriter, LaTeXWriter))
|
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
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
@pytest.fixture
|
|
|
|
def parse(settings):
|
|
|
|
def parse_(rst):
|
|
|
|
document = utils.new_document(b'test data', settings)
|
|
|
|
document['file'] = 'dummy'
|
|
|
|
parser = RstParser()
|
|
|
|
parser.parse(rst, document)
|
2017-03-14 15:43:04 -05:00
|
|
|
SmartQuotes(document, startnode=None).apply()
|
2017-01-06 09:46:26 -06:00
|
|
|
for msg in document.traverse(nodes.system_message):
|
|
|
|
if msg['level'] == 1:
|
|
|
|
msg.replace_self([])
|
|
|
|
return document
|
|
|
|
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
|
|
|
|
2017-03-14 15:43:04 -05:00
|
|
|
class ForgivingHTMLTranslator(HTMLTranslator, 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
|
|
|
|
|
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
@pytest.fixture
|
|
|
|
def verify_re_html(app, parse):
|
|
|
|
def verify(rst, html_expected):
|
|
|
|
document = parse(rst)
|
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
|
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
|
|
|
|
2017-01-06 09:46:26 -06:00
|
|
|
@pytest.fixture
|
|
|
|
def verify_re_latex(app, parse):
|
|
|
|
def verify(rst, latex_expected):
|
|
|
|
document = parse(rst)
|
2018-08-07 11:19:33 -05:00
|
|
|
app.builder = LaTeXBuilder(app)
|
|
|
|
app.builder.set_environment(app.env)
|
2019-01-07 10:30:15 -06:00
|
|
|
app.builder.init()
|
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
|
|
|
latex_translator = ForgivingLaTeXTranslator(document, app.builder)
|
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)
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
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)
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify_re_
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
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) + '$')
|
2017-01-06 09:46:26 -06:00
|
|
|
return verify_
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
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]
|
|
|
|
return get
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('type,rst,html_expected,latex_expected', [
|
|
|
|
(
|
|
|
|
# correct interpretation of code with whitespace
|
|
|
|
'verify_re',
|
|
|
|
'``code sample``',
|
2018-01-13 00:18:09 -06:00
|
|
|
('<p><code class="(samp )?docutils literal notranslate"><span class="pre">'
|
2017-01-06 09:46:26 -06:00
|
|
|
'code</span>   <span class="pre">sample</span></code></p>'),
|
2018-01-02 16:11:19 -06:00
|
|
|
r'\\sphinxcode{\\sphinxupquote{code sample}}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# correct interpretation of code with whitespace
|
|
|
|
'verify_re',
|
|
|
|
':samp:`code sample`',
|
2018-01-13 00:18:09 -06:00
|
|
|
('<p><code class="(samp )?docutils literal notranslate"><span class="pre">'
|
2017-01-06 09:46:26 -06:00
|
|
|
'code</span>   <span class="pre">sample</span></code></p>'),
|
2018-01-02 16:11:19 -06:00
|
|
|
r'\\sphinxcode{\\sphinxupquote{code sample}}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of braces in samp and file roles (HTML only)
|
|
|
|
'verify',
|
|
|
|
':samp:`a{b}c`',
|
2018-01-13 00:18:09 -06:00
|
|
|
('<p><code class="samp docutils literal notranslate">'
|
|
|
|
'<span class="pre">a</span>'
|
2017-01-06 09:46:26 -06:00
|
|
|
'<em><span class="pre">b</span></em>'
|
|
|
|
'<span class="pre">c</span></code></p>'),
|
2018-01-02 16:11:19 -06:00
|
|
|
'\\sphinxcode{\\sphinxupquote{a\\sphinxstyleemphasis{b}c}}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of arrows in menuselection
|
|
|
|
'verify',
|
|
|
|
':menuselection:`a --> b`',
|
2018-12-15 08:02:28 -06:00
|
|
|
('<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>'),
|
2017-01-06 09:46:26 -06:00
|
|
|
'\\sphinxmenuselection{a \\(\\rightarrow\\) b}',
|
|
|
|
),
|
|
|
|
(
|
2018-04-20 06:13:00 -05:00
|
|
|
# interpolation of ampersands in menuselection
|
|
|
|
'verify',
|
|
|
|
':menuselection:`&Foo -&&- &Bar`',
|
2018-12-15 08:02:28 -06:00
|
|
|
('<p><span class="menuselection"><span class="accelerator">F</span>oo '
|
2018-04-20 06:13:00 -05:00
|
|
|
'-&- <span class="accelerator">B</span>ar</span></p>'),
|
|
|
|
r'\sphinxmenuselection{\sphinxaccelerator{F}oo -\&- \sphinxaccelerator{B}ar}',
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# interpolation of ampersands in guilabel
|
2017-01-06 09:46:26 -06:00
|
|
|
'verify',
|
|
|
|
':guilabel:`&Foo -&&- &Bar`',
|
2018-12-15 08:02:28 -06:00
|
|
|
('<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
2017-01-06 09:46:26 -06:00
|
|
|
'-&- <span class="accelerator">B</span>ar</span></p>'),
|
2018-04-20 06:13:00 -05:00
|
|
|
r'\sphinxguilabel{\sphinxaccelerator{F}oo -\&- \sphinxaccelerator{B}ar}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# non-interpolation of dashes in option role
|
|
|
|
'verify_re',
|
|
|
|
':option:`--with-option`',
|
2018-01-13 00:18:09 -06:00
|
|
|
('<p><code( class="xref std std-option docutils literal notranslate")?>'
|
2017-01-06 09:46:26 -06:00
|
|
|
'<span class="pre">--with-option</span></code></p>$'),
|
2018-01-02 16:11:19 -06:00
|
|
|
r'\\sphinxcode{\\sphinxupquote{-{-}with-option}}$',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# verify smarty-pants quotes
|
|
|
|
'verify',
|
|
|
|
'"John"',
|
2018-12-15 08:02:28 -06:00
|
|
|
'<p>“John”</p>',
|
|
|
|
"“John”",
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# ... but not in literal text
|
|
|
|
'verify',
|
|
|
|
'``"John"``',
|
2018-01-13 00:18:09 -06:00
|
|
|
('<p><code class="docutils literal notranslate"><span class="pre">'
|
2017-01-06 09:46:26 -06:00
|
|
|
'"John"</span></code></p>'),
|
2018-01-02 16:11:19 -06:00
|
|
|
'\\sphinxcode{\\sphinxupquote{"John"}}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# verify classes for inline roles
|
|
|
|
'verify',
|
|
|
|
':manpage:`mp(1)`',
|
|
|
|
'<p><em class="manpage">mp(1)</em></p>',
|
2018-01-02 16:11:19 -06:00
|
|
|
'\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# correct escaping in normal mode
|
|
|
|
'verify',
|
2018-12-15 08:02:28 -06:00
|
|
|
'Γ\\\\∞$',
|
2017-01-06 09:46:26 -06:00
|
|
|
None,
|
2018-12-15 08:02:28 -06:00
|
|
|
'Γ\\textbackslash{}\\(\\infty\\)\\$',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# in verbatim code fragments
|
|
|
|
'verify',
|
2018-12-15 08:02:28 -06:00
|
|
|
'::\n\n @Γ\\∞${}',
|
2017-01-06 09:46:26 -06:00
|
|
|
None,
|
2018-12-16 11:34:05 -06:00
|
|
|
('\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
|
2018-12-15 08:02:28 -06:00
|
|
|
'@Γ\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
|
|
|
|
'\\end{sphinxVerbatim}'),
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
|
|
|
(
|
|
|
|
# in URIs
|
|
|
|
'verify_re',
|
2018-12-15 08:02:28 -06:00
|
|
|
'`test <http://example.com/~me/>`_',
|
2017-01-06 09:46:26 -06:00
|
|
|
None,
|
2017-03-11 09:53:53 -06:00
|
|
|
r'\\sphinxhref{http://example.com/~me/}{test}.*',
|
2017-01-06 09:46:26 -06:00
|
|
|
),
|
2019-01-02 21:37:59 -06:00
|
|
|
(
|
|
|
|
# description list: simple
|
|
|
|
'verify',
|
|
|
|
'term\n description',
|
|
|
|
'<dl class="docutils">\n<dt>term</dt><dd>description</dd>\n</dl>',
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# description list: with classifiers
|
|
|
|
'verify',
|
|
|
|
'term : class1 : class2\n description',
|
|
|
|
('<dl class="docutils">\n<dt>term<span class="classifier">class1</span>'
|
|
|
|
'<span class="classifier">class2</span></dt><dd>description</dd>\n</dl>'),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
# glossary (description list): multiple terms
|
|
|
|
'verify',
|
|
|
|
'.. glossary::\n\n term1\n term2\n description',
|
|
|
|
('<dl class="glossary docutils">\n<dt id="term-term1">term1</dt>'
|
|
|
|
'<dt id="term-term2">term2</dt><dd>description</dd>\n</dl>'),
|
|
|
|
None,
|
|
|
|
),
|
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
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='prolog')
|
2016-05-24 22:06:49 -05:00
|
|
|
def test_rst_prolog(app, status, warning):
|
|
|
|
app.builder.build_all()
|
2016-05-25 05:58:15 -05:00
|
|
|
rst = pickle.loads((app.doctreedir / 'restructuredtext.doctree').bytes())
|
|
|
|
md = pickle.loads((app.doctreedir / 'markdown.doctree').bytes())
|
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')
|
2016-09-10 03:38:10 -05:00
|
|
|
def test_keep_warnings_is_True(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert len(doctree[0]) == 2
|
|
|
|
assert_node(doctree[0][1], nodes.system_message)
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='keep_warnings',
|
2017-01-25 10:13:17 -06:00
|
|
|
confoverrides={'keep_warnings': False})
|
2016-09-10 03:38:10 -05:00
|
|
|
def test_keep_warnings_is_False(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
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')
|
2016-09-10 09:31:43 -05:00
|
|
|
def test_compact_refonly_bullet_list(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
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')
|
|
|
|
def test_default_role1(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
# default-role: pep
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
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)
|
|
|
|
assert_node(doctree[0][1][2], nodes.reference, classes=["pep"])
|
|
|
|
|
|
|
|
# no default-role
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes())
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('dummy', testroot='default_role',
|
|
|
|
confoverrides={'default_role': 'guilabel'})
|
|
|
|
def test_default_role2(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
# default-role directive is stronger than configratuion
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes())
|
|
|
|
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)
|
|
|
|
assert_node(doctree[0][1][2], nodes.reference, classes=["pep"])
|
|
|
|
|
|
|
|
# default_role changes the default behavior
|
|
|
|
doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes())
|
|
|
|
assert_node(doctree[0], nodes.section)
|
|
|
|
assert_node(doctree[0][1], nodes.paragraph)
|
|
|
|
assert_node(doctree[0][1][0], nodes.inline, classes=["guilabel"])
|
|
|
|
assert_node(doctree[0][1][1], nodes.Text)
|