1 #! /usr/bin/env python3
3 # Author: engelbert gruber <grubert@users.sourceforge.net>
4 # Copyright: This module has been placed in the public domain.
7 Tests for manpage writer.
10 from test
import DocutilsTestSupport
15 s
= DocutilsTestSupport
.PublishTestSuite('manpage', suite_settings
=settings
)
16 s
.generateTests(totest
)
21 .nr rst2man-indent-level 0
25 level \\n[rst2man-indent-level]
26 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
33 .\" .rstReportMargin pre
:
35 . nr rst2man
-indent
\\n
[rst2man
-indent
-level
] \\n
[an
-margin
]
36 . nr rst2man
-indent
-level
+1
37 .\" .rstReportMargin post
:
41 .\" indent
\\n
[an
-margin
]
42 .\" old
: \\n
[rst2man
-indent
\\n
[rst2man
-indent
-level
]]
43 .nr rst2man
-indent
-level
-1
44 .\" new
: \\n
[rst2man
-indent
\\n
[rst2man
-indent
-level
]]
45 .in \\n
[rst2man
-indent
\\n
[rst2man
-indent
-level
]]u
53 r""".\" Man page generated
from reStructuredText
.
55 """ + indend_macros + r""".TH
"" "" ""
58 .\" Generated by docutils manpage writer
.
65 This broke docutils
-sphinx
.
68 r""".\" Man page generated
from reStructuredText
.
70 """ + indend_macros + r""".TH
"HELLO, WORLD." "" ""
77 This broke docutils\
-sphinx
.
80 .\" Generated by docutils manpage writer
.
95 :Author
: someone
@somewhere.net
97 :Copyright
: public domain
100 :Manual group
: text processing
101 :Arbitrary field
: some text
108 K
.I
.S
.S keep it simple
.
113 General rule of life
.
118 --config
=<file> Read configuration settings
from <file>, if it exists
.
119 --version
, -V Show this program
's version number and exit.
120 --help, -h Show this help message and exit.
129 Admonition with title
134 .. admonition:: homegrown
138 . period at line start.
140 and . in a line and at line start
143 r""".\" Man page generated from reStructuredText.
145 """ + indend_macros + r""".TH "SIMPLE" 1 "2009-08-05" "0.1" "text processing"
147 simple \- The way to go
154 K.I.S.S keep it simple.
161 General rule of life.
165 .BI \-\-config\fB= <file>
166 Read configuration settings from <file>, if it exists.
168 .B \-\-version\fP,\fB \-V
169 Show this program\(aqs version number and exit.
171 .B \-\-help\fP,\fB \-h
172 Show this help message and exit.
181 Admonition with title
198 \&. period at line start.
200 and . in a line and at line start
203 someone@somewhere.net
205 Arbitrary field: some text
208 .\" Generated by docutils manpage writer.
223 .\\" Man page generated from reStructuredText.
225 ''' + indend_macros + '''.TH "" "" ""
255 .\\" Generated by docutils manpage writer.
260 totest['optiongroup
'] = [
262 optin group with dot as group item
280 .\\" Man page generated from reStructuredText.
282 """ + indend_macros + """.TH "" "" ""
285 optin group with dot as group item
311 .\\" Generated by docutils manpage writer.
316 totest['definitionlist
'] = [
322 :Abstract: Docinfo is required.
329 Description of Term 1 Description of Term 1 Description of Term 1
330 Description of Term 1 Description of Term 1
332 Description of Term 1 Description of Term 1 Description of Term 1
333 Description of Term 1 Description of Term 1
337 .\\" Man page generated from reStructuredText.
339 ''' + indend_macros + '''.TH "DEFINITION LIST TEST" "" ""
341 Definition List Test \\- \n\
342 ''' + '''.SS Abstract
349 Description of Term 1 Description of Term 1 Description of Term 1
350 Description of Term 1 Description of Term 1
352 Description of Term 1 Description of Term 1 Description of Term 1
353 Description of Term 1 Description of Term 1
355 .\\" Generated by docutils manpage writer.
360 totest['cmdlineoptions
'] = [
361 ["""optional arguments:
362 -h, --help show this help
363 --output FILE, -o FILE output filename
364 -i DEVICE, --input DEVICE input device
366 r""".\" Man page generated from reStructuredText.
368 """ + indend_macros + r""".TH "" "" ""
373 .B optional arguments:
376 .B \-h\fP,\fB \-\-help
379 .BI \-\-output \ FILE\fR,\fB \ \-o \ FILE
382 .BI \-i \ DEVICE\fR,\fB \ \-\-input \ DEVICE
386 .\" Generated by docutils manpage writer.
391 totest['citation
'] = [
392 [""".. [docutils] blah blah blah
395 r""".\" Man page generated from reStructuredText.
397 """ + indend_macros + r""".TH "" "" ""
402 .IP [empty_citation] 5
403 .\" Generated by docutils manpage writer.
409 [""".. rubric:: some rubric
414 r""".\" Man page generated from reStructuredText.
416 """ + indend_macros + r""".TH "" "" ""
426 .\" Generated by docutils manpage writer.
431 totest['double_quote
'] = [
432 ["""in "defintion list"
433 double quotes must be escaped on macro invocations.
435 They are "escaped" anywhere.
437 r""".\" Man page generated from reStructuredText.
439 """ + indend_macros + r""".TH "" "" ""
444 .B in \(dqdefintion list\(dq
445 double quotes must be escaped on macro invocations.
448 They are \(dqescaped\(dq anywhere.
449 .\" Generated by docutils manpage writer.
454 totest['man_header
'] = [
464 :Manual group: the books
468 Test title, docinfo to man page header.
470 r""".\" Man page generated from reStructuredText.
472 """ + indend_macros + r""".TH "PAGE TITLE" 3 "3/Nov/2022" "0.0" "the books"
474 page title \- in short
476 Test title, docinfo to man page header.
477 .\" Generated by docutils manpage writer.
483 if __name__ == '__main__
':
485 unittest.main(defaultTest='suite
')