fix manpage test
[docutils.git] / test / test_writers / test_manpage.py
blobfaf4b900bc785b3b0f62f22f708d0ed3579dc8e3
1 #! /usr/bin/env python
3 # $Id: test_latex2e.py 6003 2009-06-27 20:44:09Z milde $
4 # Author: engelbert gruber <grubert@users.sourceforge.net>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for manpage writer.
9 """
11 from __init__ import DocutilsTestSupport
13 from docutils._compat import b
15 def suite():
16 settings = {}
17 s = DocutilsTestSupport.PublishTestSuite('manpage', suite_settings=settings)
18 s.generateTests(totest)
19 return s
21 indend_macros = r""".
22 .nr rst2man-indent-level 0
24 .de1 rstReportMargin
25 \\$1 \\n[an-margin]
26 level \\n[rst2man-indent-level]
27 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 \\n[rst2man-indent0]
30 \\n[rst2man-indent1]
31 \\n[rst2man-indent2]
33 .de1 INDENT
34 .\" .rstReportMargin pre:
35 . RS \\$1
36 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
37 . nr rst2man-indent-level +1
38 .\" .rstReportMargin post:
40 .de UNINDENT
41 . RE
42 .\" indent \\n[an-margin]
43 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
44 .nr rst2man-indent-level -1
45 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
46 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
48 """
50 totest = {}
52 totest['blank'] = [
53 ["",
54 r""".TH "" "" ""
55 .SH NAME
56 \-
57 .\" Man page generated from reStructuredText.
59 .\" Generated by docutils manpage writer.
61 """],
64 totest['simple'] = [
65 ["""\
66 ========
67 simple
68 ========
70 ---------------
71 The way to go
72 ---------------
74 :Author: someone@somewhere.net
75 :Date: 2009-08-05
76 :Copyright: public domain
77 :Version: 0.1
78 :Manual section: 1
79 :Manual group: text processing
80 :Arbitrary field: some text
82 SYNOPSIS
83 ========
87 K.I.S.S keep it simple.
89 DESCRIPTION
90 ===========
92 General rule of life.
94 OPTIONS
95 =======
97 --config=<file> Read configuration settings from <file>, if it exists.
98 --version, -V Show this program's version number and exit.
99 --help, -h Show this help message and exit.
101 OtHeR SECTION
102 =============
104 With mixed case.
106 .. Attention::
108 Admonition with title
110 * bullet list
111 * bull and list
113 .. admonition:: homegrown
115 something important
117 """,
118 r""".\" Man page generated from reStructuredText.
120 .TH SIMPLE 1 "2009-08-05" "0.1" "text processing"
121 .SH NAME
122 simple \- The way to go
123 """+indend_macros+
124 r""".SH SYNOPSIS
125 .INDENT 0.0
126 .INDENT 3.5
129 .ft C
130 K.I.S.S keep it simple.
131 .ft P
133 .UNINDENT
134 .UNINDENT
135 .SH DESCRIPTION
137 General rule of life.
138 .SH OPTIONS
139 .INDENT 0.0
141 .BI \-\-config\fB= <file>
142 Read configuration settings from <file>, if it exists.
144 .B \-\-version\fP,\fB \-V
145 Show this program\(aqs version number and exit.
147 .B \-\-help\fP,\fB \-h
148 Show this help message and exit.
149 .UNINDENT
150 .SH OTHER SECTION
152 With mixed case.
154 \fBATTENTION!:\fP
155 .INDENT 0.0
156 .INDENT 3.5
157 Admonition with title
158 .INDENT 0.0
159 .IP \(bu 2
160 bullet list
161 .IP \(bu 2
162 bull and list
163 .UNINDENT
164 .UNINDENT
165 .UNINDENT
166 .INDENT 0.0
167 .INDENT 3.5
168 .IP "homegrown"
170 something important
171 .UNINDENT
172 .UNINDENT
173 .SH AUTHOR
174 someone@somewhere.net
176 Arbitrary field: some text
177 .SH COPYRIGHT
178 public domain
179 .\" Generated by docutils manpage writer.
181 """],
184 totest['table'] = [
185 ["""\
186 ====== =====
187 head and
188 ====== =====
190 abc so
191 ====== =====
192 """,
193 '''\
194 .TH "" "" ""
195 .SH NAME
196 \\- \n\
197 .\\" Man page generated from reStructuredText.
199 .INDENT 0.0
200 .INDENT 3.5
202 center;
203 |l|l|.
206 head
207 T}\tT{
213 T}\tT{
219 T}\tT{
224 .UNINDENT
225 .UNINDENT
226 .\\" Generated by docutils manpage writer.
228 ''']
231 totest['optiongroup'] = [
232 ["""
233 optin group with dot as group item
236 bla bla bla
239 bla bla bla
242 bla bla bla
245 bla bla bla
248 bla bla bla
249 """,
250 """\
251 .TH "" "" ""
252 .SH NAME
253 \\- \n\
254 .\\" Man page generated from reStructuredText.
256 optin group with dot as group item
257 .INDENT 0.0
259 .B $
260 bla bla bla
261 .UNINDENT
262 .INDENT 0.0
264 .B #
265 bla bla bla
266 .UNINDENT
267 .INDENT 0.0
269 .B .
270 bla bla bla
271 .UNINDENT
272 .INDENT 0.0
274 .B [
275 bla bla bla
276 .UNINDENT
277 .INDENT 0.0
279 .B ]
280 bla bla bla
281 .UNINDENT
282 .\\" Generated by docutils manpage writer.
283 ."""],
286 totest['definitionlist'] = [
287 ["""
288 ====================
289 Definition List Test
290 ====================
292 :Abstract: Docinfo is required.
294 Section
295 =======
297 :term1:
299 Description of Term 1 Description of Term 1 Description of Term 1
300 Description of Term 1 Description of Term 1
302 Description of Term 1 Description of Term 1 Description of Term 1
303 Description of Term 1 Description of Term 1
305 """,
306 '''\
307 .TH DEFINITION LIST TEST "" "" ""
308 .SH NAME
309 Definition List Test \\- \n\
310 .\\" Man page generated from reStructuredText.
312 .SS Abstract
314 Docinfo is required.
315 .SH SECTION
316 .INDENT 0.0
318 .B term1
319 Description of Term 1 Description of Term 1 Description of Term 1
320 Description of Term 1 Description of Term 1
322 Description of Term 1 Description of Term 1 Description of Term 1
323 Description of Term 1 Description of Term 1
324 .UNINDENT
325 .\\" Generated by docutils manpage writer.
326 .'''],
330 if __name__ == '__main__':
331 import unittest
332 unittest.main(defaultTest='suite')