regression test for sphinx admonition
[docutils.git] / test / test_writers / test_manpage.py
blobda9a77b3cbf4c86fc2afda05e5dfeb3d618d58e2
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""".\" Man page generated from reStructuredText.
56 .TH "" "" ""
57 .SH NAME
58 \-
59 """+indend_macros+
60 r""".\" Generated by docutils manpage writer.
62 """],
63 [r"""Hello, world.
64 =============
66 .. WARNING::
67 This broke docutils-sphinx.
69 """,
70 r""".\" Man page generated from reStructuredText.
72 .TH HELLO, WORLD. "" "" ""
73 .SH NAME
74 Hello, world. \-
75 """+indend_macros+
76 r""".sp
77 \fBWARNING:\fP
78 .INDENT 0.0
79 .INDENT 3.5
80 This broke docutils\-sphinx.
81 .UNINDENT
82 .UNINDENT
83 .\" Generated by docutils manpage writer.
85 """],
88 totest['simple'] = [
89 ["""\
90 ========
91 simple
92 ========
94 ---------------
95 The way to go
96 ---------------
98 :Author: someone@somewhere.net
99 :Date: 2009-08-05
100 :Copyright: public domain
101 :Version: 0.1
102 :Manual section: 1
103 :Manual group: text processing
104 :Arbitrary field: some text
106 SYNOPSIS
107 ========
111 K.I.S.S keep it simple.
113 DESCRIPTION
114 ===========
116 General rule of life.
118 OPTIONS
119 =======
121 --config=<file> Read configuration settings from <file>, if it exists.
122 --version, -V Show this program's version number and exit.
123 --help, -h Show this help message and exit.
125 OtHeR SECTION
126 =============
128 With mixed case.
130 .. Attention::
132 Admonition with title
134 * bullet list
135 * bull and list
137 .. admonition:: homegrown
139 something important
141 """,
142 r""".\" Man page generated from reStructuredText.
144 .TH SIMPLE 1 "2009-08-05" "0.1" "text processing"
145 .SH NAME
146 simple \- The way to go
147 """+indend_macros+
148 r""".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
197 .SH AUTHOR
198 someone@somewhere.net
200 Arbitrary field: some text
201 .SH COPYRIGHT
202 public domain
203 .\" Generated by docutils manpage writer.
205 """],
208 totest['table'] = [
209 ["""\
210 ====== =====
211 head and
212 ====== =====
214 abc so
215 ====== =====
216 """,
217 '''\
218 .\\" Man page generated from reStructuredText.
220 .TH "" "" ""
221 .SH NAME
222 \\- \n\
223 '''+indend_macros+
224 '''.INDENT 0.0
225 .INDENT 3.5
227 center;
228 |l|l|.
231 head
232 T}\tT{
238 T}\tT{
244 T}\tT{
249 .UNINDENT
250 .UNINDENT
251 .\\" Generated by docutils manpage writer.
253 ''']
256 totest['optiongroup'] = [
257 ["""
258 optin group with dot as group item
261 bla bla bla
264 bla bla bla
267 bla bla bla
270 bla bla bla
273 bla bla bla
274 """,
275 """\
276 .\\" Man page generated from reStructuredText.
278 .TH "" "" ""
279 .SH NAME
280 \\- \n\
281 """+indend_macros+
282 """optin group with dot as group item
283 .INDENT 0.0
285 .B $
286 bla bla bla
287 .UNINDENT
288 .INDENT 0.0
290 .B #
291 bla bla bla
292 .UNINDENT
293 .INDENT 0.0
295 .B .
296 bla bla bla
297 .UNINDENT
298 .INDENT 0.0
300 .B [
301 bla bla bla
302 .UNINDENT
303 .INDENT 0.0
305 .B ]
306 bla bla bla
307 .UNINDENT
308 .\\" Generated by docutils manpage writer.
309 ."""],
312 totest['definitionlist'] = [
313 ["""
314 ====================
315 Definition List Test
316 ====================
318 :Abstract: Docinfo is required.
320 Section
321 =======
323 :term1:
325 Description of Term 1 Description of Term 1 Description of Term 1
326 Description of Term 1 Description of Term 1
328 Description of Term 1 Description of Term 1 Description of Term 1
329 Description of Term 1 Description of Term 1
331 """,
332 '''\
333 .\\" Man page generated from reStructuredText.
335 .TH DEFINITION LIST TEST "" "" ""
336 .SH NAME
337 Definition List Test \\- \n\
338 '''+indend_macros+
339 '''.SS Abstract
341 Docinfo is required.
342 .SH SECTION
343 .INDENT 0.0
345 .B term1
346 Description of Term 1 Description of Term 1 Description of Term 1
347 Description of Term 1 Description of Term 1
349 Description of Term 1 Description of Term 1 Description of Term 1
350 Description of Term 1 Description of Term 1
351 .UNINDENT
352 .\\" Generated by docutils manpage writer.
353 .'''],
357 if __name__ == '__main__':
358 import unittest
359 unittest.main(defaultTest='suite')