1""" 2 test_build_manpage 3 ~~~~~~~~~~~~~~~~~~ 4 5 Test the build process with manpage builder with the test root. 6 7 :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. 8 :license: BSD, see LICENSE for details. 9""" 10 11import pytest 12 13from sphinx.builders.manpage import default_man_pages 14from sphinx.config import Config 15 16 17@pytest.mark.sphinx('man') 18def test_all(app, status, warning): 19 app.builder.build_all() 20 assert (app.outdir / 'sphinxtests.1').exists() 21 22 content = (app.outdir / 'sphinxtests.1').read_text() 23 assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content 24 assert r'\fBmanpage\en\fP' in content 25 26 # term of definition list including nodes.strong 27 assert '\n.B term1\n' in content 28 assert '\nterm2 (\\fBstronged partially\\fP)\n' in content 29 30 assert 'Footnotes' not in content 31 32 33@pytest.mark.sphinx('man', testroot='basic', 34 confoverrides={'man_make_section_directory': True}) 35def test_man_make_section_directory(app, status, warning): 36 app.build() 37 assert (app.outdir / '1' / 'python.1').exists() 38 39 40@pytest.mark.sphinx('man', testroot='directive-code') 41def test_captioned_code_block(app, status, warning): 42 app.builder.build_all() 43 content = (app.outdir / 'python.1').read_text() 44 45 assert ('.sp\n' 46 'caption \\fItest\\fP rb\n' 47 '.INDENT 0.0\n' 48 '.INDENT 3.5\n' 49 '.sp\n' 50 '.nf\n' 51 '.ft C\n' 52 'def ruby?\n' 53 ' false\n' 54 'end\n' 55 '.ft P\n' 56 '.fi\n' 57 '.UNINDENT\n' 58 '.UNINDENT\n' in content) 59 60 61def test_default_man_pages(): 62 config = Config({'project': 'STASI™ Documentation', 63 'author': "Wolfgang Schäuble & G'Beckstein", 64 'release': '1.0'}) 65 config.init_values() 66 expected = [('index', 'stasi', 'STASI™ Documentation 1.0', 67 ["Wolfgang Schäuble & G'Beckstein"], 1)] 68 assert default_man_pages(config) == expected 69 70 71@pytest.mark.sphinx('man', testroot='markup-rubric') 72def test_rubric(app, status, warning): 73 app.build() 74 content = (app.outdir / 'python.1').read_text() 75 assert 'This is a rubric\n' in content 76