2016-01-08 16:00:26 +09:00
|
|
|
"""Test the build process with manpage builder with the test root."""
|
|
|
|
|
|
2023-08-05 06:46:41 +03:00
|
|
|
import docutils
|
2017-01-06 01:14:47 +09:00
|
|
|
import pytest
|
2016-01-08 16:00:26 +09:00
|
|
|
|
2018-11-24 01:08:50 +09:00
|
|
|
from sphinx.builders.manpage import default_man_pages
|
|
|
|
|
from sphinx.config import Config
|
|
|
|
|
|
2016-01-08 16:00:26 +09:00
|
|
|
|
2017-01-06 01:14:47 +09:00
|
|
|
@pytest.mark.sphinx('man')
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_all(app):
|
2024-01-17 02:38:46 +00:00
|
|
|
app.build(force_all=True)
|
2021-05-15 22:17:20 +09:00
|
|
|
assert (app.outdir / 'sphinxtests.1').exists()
|
2016-01-08 16:00:26 +09:00
|
|
|
|
2022-04-27 03:04:19 +01:00
|
|
|
content = (app.outdir / 'sphinxtests.1').read_text(encoding='utf8')
|
2016-01-08 16:00:26 +09:00
|
|
|
assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content
|
2016-01-08 22:17:45 +09:00
|
|
|
assert r'\fBmanpage\en\fP' in content
|
2016-03-06 17:49:49 +09:00
|
|
|
|
2021-09-11 18:47:24 +09:00
|
|
|
# heading (title + description)
|
|
|
|
|
assert r'sphinxtests \- Sphinx <Tests> 0.6alpha1' in content
|
|
|
|
|
|
2016-03-06 17:49:49 +09:00
|
|
|
# term of definition list including nodes.strong
|
|
|
|
|
assert '\n.B term1\n' in content
|
|
|
|
|
assert '\nterm2 (\\fBstronged partially\\fP)\n' in content
|
2018-11-24 01:08:50 +09:00
|
|
|
|
2021-06-16 09:21:46 +02:00
|
|
|
# test samp with braces
|
|
|
|
|
assert '\n\\fIvariable_only\\fP\n' in content
|
|
|
|
|
assert '\n\\fIvariable\\fP\\fB and text\\fP\n' in content
|
|
|
|
|
assert '\n\\fBShow \\fP\\fIvariable\\fP\\fB in the middle\\fP\n' in content
|
|
|
|
|
|
2018-12-09 00:35:46 +09:00
|
|
|
assert 'Footnotes' not in content
|
|
|
|
|
|
2018-11-24 01:08:50 +09:00
|
|
|
|
2021-09-11 18:47:24 +09:00
|
|
|
@pytest.mark.sphinx('man', testroot='basic',
|
|
|
|
|
confoverrides={'man_pages': [('index', 'title', None, [], 1)]})
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_man_pages_empty_description(app):
|
2024-01-17 02:38:46 +00:00
|
|
|
app.build(force_all=True)
|
2021-09-11 18:47:24 +09:00
|
|
|
|
2022-04-27 03:04:19 +01:00
|
|
|
content = (app.outdir / 'title.1').read_text(encoding='utf8')
|
2021-09-11 18:47:24 +09:00
|
|
|
assert r'title \-' not in content
|
|
|
|
|
|
|
|
|
|
|
2020-10-03 22:26:32 +09:00
|
|
|
@pytest.mark.sphinx('man', testroot='basic',
|
2021-05-15 22:17:20 +09:00
|
|
|
confoverrides={'man_make_section_directory': True})
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_man_make_section_directory(app):
|
2020-10-03 22:26:32 +09:00
|
|
|
app.build()
|
2024-07-10 21:43:14 +01:00
|
|
|
assert (app.outdir / 'man1' / 'projectnamenotset.1').exists()
|
2020-10-03 22:26:32 +09:00
|
|
|
|
|
|
|
|
|
2019-03-10 02:03:11 +09:00
|
|
|
@pytest.mark.sphinx('man', testroot='directive-code')
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_captioned_code_block(app):
|
2024-01-17 02:38:46 +00:00
|
|
|
app.build(force_all=True)
|
2024-07-10 21:43:14 +01:00
|
|
|
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
2019-03-10 02:03:11 +09:00
|
|
|
|
2023-08-05 06:46:41 +03:00
|
|
|
if docutils.__version_info__[:2] < (0, 21):
|
|
|
|
|
expected = """\
|
|
|
|
|
.sp
|
|
|
|
|
caption \\fItest\\fP rb
|
|
|
|
|
.INDENT 0.0
|
|
|
|
|
.INDENT 3.5
|
|
|
|
|
.sp
|
|
|
|
|
.nf
|
|
|
|
|
.ft C
|
|
|
|
|
def ruby?
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
.ft P
|
|
|
|
|
.fi
|
|
|
|
|
.UNINDENT
|
|
|
|
|
.UNINDENT
|
|
|
|
|
"""
|
|
|
|
|
else:
|
|
|
|
|
expected = """\
|
|
|
|
|
.sp
|
|
|
|
|
caption \\fItest\\fP rb
|
|
|
|
|
.INDENT 0.0
|
|
|
|
|
.INDENT 3.5
|
|
|
|
|
.sp
|
|
|
|
|
.EX
|
|
|
|
|
def ruby?
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
.EE
|
|
|
|
|
.UNINDENT
|
|
|
|
|
.UNINDENT
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
assert expected in content
|
2019-03-10 16:52:51 +09:00
|
|
|
|
|
|
|
|
|
2018-11-24 01:08:50 +09:00
|
|
|
def test_default_man_pages():
|
2019-01-02 22:20:22 +09:00
|
|
|
config = Config({'project': 'STASI™ Documentation',
|
2018-12-15 23:02:28 +09:00
|
|
|
'author': "Wolfgang Schäuble & G'Beckstein",
|
2018-11-24 01:08:50 +09:00
|
|
|
'release': '1.0'})
|
2018-12-15 23:02:28 +09:00
|
|
|
expected = [('index', 'stasi', 'STASI™ Documentation 1.0',
|
|
|
|
|
["Wolfgang Schäuble & G'Beckstein"], 1)]
|
2018-11-24 01:08:50 +09:00
|
|
|
assert default_man_pages(config) == expected
|
2019-05-06 21:27:43 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('man', testroot='markup-rubric')
|
2024-07-23 15:35:55 +01:00
|
|
|
def test_rubric(app):
|
2019-05-06 21:27:43 +09:00
|
|
|
app.build()
|
2024-07-10 21:43:14 +01:00
|
|
|
content = (app.outdir / 'projectnamenotset.1').read_text(encoding='utf8')
|
2019-05-06 21:27:43 +09:00
|
|
|
assert 'This is a rubric\n' in content
|