test_manpage: add docinfo to man header
[docutils.git] / docutils / test / test_writers / test_manpage.py
blobcdd207550f01808741e9c9c36e0c0ac13d7c3796
1 #! /usr/bin/env python3
3 # Author: engelbert gruber <grubert@users.sourceforge.net>
4 # Copyright: This module has been placed in the public domain.
6 """
7 Tests for manpage writer.
8 """
10 from test import DocutilsTestSupport
13 def suite():
14 settings = {}
15 s = DocutilsTestSupport.PublishTestSuite('manpage', suite_settings=settings)
16 s.generateTests(totest)
17 return s
20 indend_macros = r""".
21 .nr rst2man-indent-level 0
23 .de1 rstReportMargin
24 \\$1 \\n[an-margin]
25 level \\n[rst2man-indent-level]
26 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
28 \\n[rst2man-indent0]
29 \\n[rst2man-indent1]
30 \\n[rst2man-indent2]
32 .de1 INDENT
33 .\" .rstReportMargin pre:
34 . RS \\$1
35 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
36 . nr rst2man-indent-level +1
37 .\" .rstReportMargin post:
39 .de UNINDENT
40 . RE
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
47 """
49 totest = {}
51 totest['blank'] = [
52 ["",
53 r""".\" Man page generated from reStructuredText.
55 """ + indend_macros + r""".TH "" "" ""
56 .SH NAME
57 \-
58 .\" Generated by docutils manpage writer.
60 """],
61 [r"""Hello, world.
62 =============
64 .. WARNING::
65 This broke docutils-sphinx.
67 """,
68 r""".\" Man page generated from reStructuredText.
70 """ + indend_macros + r""".TH "HELLO, WORLD." "" ""
71 .SH NAME
72 Hello, world. \-
73 .sp
74 \fBWARNING:\fP
75 .INDENT 0.0
76 .INDENT 3.5
77 This broke docutils\-sphinx.
78 .UNINDENT
79 .UNINDENT
80 .\" Generated by docutils manpage writer.
82 """],
85 totest['simple'] = [
86 ["""\
87 ========
88 simple
89 ========
91 ---------------
92 The way to go
93 ---------------
95 :Author: someone@somewhere.net
96 :Date: 2009-08-05
97 :Copyright: public domain
98 :Version: 0.1
99 :Manual section: 1
100 :Manual group: text processing
101 :Arbitrary field: some text
103 SYNOPSIS
104 ========
108 K.I.S.S keep it simple.
110 DESCRIPTION
111 ===========
113 General rule of life.
115 OPTIONS
116 =======
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.
122 OtHeR SECTION
123 =============
125 With mixed case.
127 .. Attention::
129 Admonition with title
131 * bullet list
132 * bull and list
134 .. admonition:: homegrown
136 something important
138 . period at line start.
140 and . in a line and at line start
141 .in a paragraph
142 """,
143 r""".\" Man page generated from reStructuredText.
145 """ + indend_macros + r""".TH "SIMPLE" 1 "2009-08-05" "0.1" "text processing"
146 .SH NAME
147 simple \- The way to go
148 .SH SYNOPSIS
149 .INDENT 0.0
150 .INDENT 3.5
153 .ft C
154 K.I.S.S keep it simple.
155 .ft P
157 .UNINDENT
158 .UNINDENT
159 .SH DESCRIPTION
161 General rule of life.
162 .SH OPTIONS
163 .INDENT 0.0
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.
173 .UNINDENT
174 .SH OTHER SECTION
176 With mixed case.
178 \fBATTENTION!:\fP
179 .INDENT 0.0
180 .INDENT 3.5
181 Admonition with title
182 .INDENT 0.0
183 .IP \(bu 2
184 bullet list
185 .IP \(bu 2
186 bull and list
187 .UNINDENT
188 .UNINDENT
189 .UNINDENT
190 .INDENT 0.0
191 .INDENT 3.5
192 .IP "homegrown"
194 something important
195 .UNINDENT
196 .UNINDENT
198 \&. period at line start.
200 and . in a line and at line start
201 \&.in a paragraph
202 .SH AUTHOR
203 someone@somewhere.net
205 Arbitrary field: some text
206 .SH COPYRIGHT
207 public domain
208 .\" Generated by docutils manpage writer.
210 """],
213 totest['table'] = [
214 ["""\
215 ====== =====
216 head and
217 ====== =====
219 abc so
220 ====== =====
221 """,
222 '''\
223 .\\" Man page generated from reStructuredText.
225 ''' + indend_macros + '''.TH "" "" ""
226 .SH NAME
227 \\- \n\
228 .INDENT 0.0
229 .INDENT 3.5
231 center;
232 |l|l|.
235 head
236 T}\tT{
242 T}\tT{
248 T}\tT{
253 .UNINDENT
254 .UNINDENT
255 .\\" Generated by docutils manpage writer.
257 ''']
260 totest['optiongroup'] = [
261 ["""
262 optin group with dot as group item
265 bla bla bla
268 bla bla bla
271 bla bla bla
274 bla bla bla
277 bla bla bla
278 """,
279 """\
280 .\\" Man page generated from reStructuredText.
282 """ + indend_macros + """.TH "" "" ""
283 .SH NAME
284 \\- \n\
285 optin group with dot as group item
286 .INDENT 0.0
288 .B $
289 bla bla bla
290 .UNINDENT
291 .INDENT 0.0
293 .B #
294 bla bla bla
295 .UNINDENT
296 .INDENT 0.0
298 .B \\&.
299 bla bla bla
300 .UNINDENT
301 .INDENT 0.0
303 .B [
304 bla bla bla
305 .UNINDENT
306 .INDENT 0.0
308 .B ]
309 bla bla bla
310 .UNINDENT
311 .\\" Generated by docutils manpage writer.
313 """],
316 totest['definitionlist'] = [
317 ["""
318 ====================
319 Definition List Test
320 ====================
322 :Abstract: Docinfo is required.
324 Section
325 =======
327 :term1:
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
335 """,
336 '''\
337 .\\" Man page generated from reStructuredText.
339 ''' + indend_macros + '''.TH "DEFINITION LIST TEST" "" ""
340 .SH NAME
341 Definition List Test \\- \n\
342 ''' + '''.SS Abstract
344 Docinfo is required.
345 .SH SECTION
346 .INDENT 0.0
348 .B term1
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
354 .UNINDENT
355 .\\" Generated by docutils manpage writer.
357 '''],
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
365 """,
366 r""".\" Man page generated from reStructuredText.
368 """ + indend_macros + r""".TH "" "" ""
369 .SH NAME
371 .INDENT 0.0
373 .B optional arguments:
374 .INDENT 7.0
376 .B \-h\fP,\fB \-\-help
377 show this help
379 .BI \-\-output \ FILE\fR,\fB \ \-o \ FILE
380 output filename
382 .BI \-i \ DEVICE\fR,\fB \ \-\-input \ DEVICE
383 input device
384 .UNINDENT
385 .UNINDENT
386 .\" Generated by docutils manpage writer.
388 """],
391 totest['citation'] = [
392 [""".. [docutils] blah blah blah
393 .. [empty_citation]
394 """,
395 r""".\" Man page generated from reStructuredText.
397 """ + indend_macros + r""".TH "" "" ""
398 .SH NAME
400 .IP [docutils] 5
401 blah blah blah
402 .IP [empty_citation] 5
403 .\" Generated by docutils manpage writer.
405 """],
408 totest['rubric'] = [
409 [""".. rubric:: some rubric
411 - followed by
412 - a list
413 """,
414 r""".\" Man page generated from reStructuredText.
416 """ + indend_macros + r""".TH "" "" ""
417 .SH NAME
419 some rubric
420 .INDENT 0.0
421 .IP \(bu 2
422 followed by
423 .IP \(bu 2
424 a list
425 .UNINDENT
426 .\" Generated by docutils manpage writer.
428 """],
431 totest['double_quote'] = [
432 ["""in "defintion list"
433 double quotes must be escaped on macro invocations.
435 They are "escaped" anywhere.
436 """,
437 r""".\" Man page generated from reStructuredText.
439 """ + indend_macros + r""".TH "" "" ""
440 .SH NAME
442 .INDENT 0.0
444 .B in \(dqdefintion list\(dq
445 double quotes must be escaped on macro invocations.
446 .UNINDENT
448 They are \(dqescaped\(dq anywhere.
449 .\" Generated by docutils manpage writer.
451 """],
454 totest['man_header'] = [
455 ["""
456 ============
457 page title
458 ============
460 in short
461 --------
463 :Manual section: 3
464 :Manual group: the books
465 :Version: 0.0
466 :Date: 3/Nov/2022
468 Test title, docinfo to man page header.
469 """,
470 r""".\" Man page generated from reStructuredText.
472 """ + indend_macros + r""".TH "PAGE TITLE" 3 "3/Nov/2022" "0.0" "the books"
473 .SH NAME
474 page title \- in short
476 Test title, docinfo to man page header.
477 .\" Generated by docutils manpage writer.
479 """],
483 if __name__ == '__main__':
484 import unittest
485 unittest.main(defaultTest='suite')