HACK around tests that depend on directory contents.
[docutils.git] / test / test_writers / test_manpage.py
blob3bbfbcbe62602086eab531715fbd83bb31cc157a
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 . period at line start.
142 """,
143 r""".\" Man page generated from reStructuredText.
145 .TH SIMPLE 1 "2009-08-05" "0.1" "text processing"
146 .SH NAME
147 simple \- The way to go
148 """+indend_macros+
149 r""".SH SYNOPSIS
150 .INDENT 0.0
151 .INDENT 3.5
154 .ft C
155 K.I.S.S keep it simple.
156 .ft P
158 .UNINDENT
159 .UNINDENT
160 .SH DESCRIPTION
162 General rule of life.
163 .SH OPTIONS
164 .INDENT 0.0
166 .BI \-\-config\fB= <file>
167 Read configuration settings from <file>, if it exists.
169 .B \-\-version\fP,\fB \-V
170 Show this program\(aqs version number and exit.
172 .B \-\-help\fP,\fB \-h
173 Show this help message and exit.
174 .UNINDENT
175 .SH OTHER SECTION
177 With mixed case.
179 \fBATTENTION!:\fP
180 .INDENT 0.0
181 .INDENT 3.5
182 Admonition with title
183 .INDENT 0.0
184 .IP \(bu 2
185 bullet list
186 .IP \(bu 2
187 bull and list
188 .UNINDENT
189 .UNINDENT
190 .UNINDENT
191 .INDENT 0.0
192 .INDENT 3.5
193 .IP "homegrown"
195 something important
196 .UNINDENT
197 .UNINDENT
199 \&. period at line start.
200 .SH AUTHOR
201 someone@somewhere.net
203 Arbitrary field: some text
204 .SH COPYRIGHT
205 public domain
206 .\" Generated by docutils manpage writer.
208 """],
211 totest['table'] = [
212 ["""\
213 ====== =====
214 head and
215 ====== =====
217 abc so
218 ====== =====
219 """,
220 '''\
221 .\\" Man page generated from reStructuredText.
223 .TH "" "" ""
224 .SH NAME
225 \\- \n\
226 '''+indend_macros+
227 '''.INDENT 0.0
228 .INDENT 3.5
230 center;
231 |l|l|.
234 head
235 T}\tT{
241 T}\tT{
247 T}\tT{
252 .UNINDENT
253 .UNINDENT
254 .\\" Generated by docutils manpage writer.
256 ''']
259 totest['optiongroup'] = [
260 ["""
261 optin group with dot as group item
264 bla bla bla
267 bla bla bla
270 bla bla bla
273 bla bla bla
276 bla bla bla
277 """,
278 """\
279 .\\" Man page generated from reStructuredText.
281 .TH "" "" ""
282 .SH NAME
283 \\- \n\
284 """+indend_macros+
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.
312 ."""],
315 totest['definitionlist'] = [
316 ["""
317 ====================
318 Definition List Test
319 ====================
321 :Abstract: Docinfo is required.
323 Section
324 =======
326 :term1:
328 Description of Term 1 Description of Term 1 Description of Term 1
329 Description of Term 1 Description of Term 1
331 Description of Term 1 Description of Term 1 Description of Term 1
332 Description of Term 1 Description of Term 1
334 """,
335 '''\
336 .\\" Man page generated from reStructuredText.
338 .TH DEFINITION LIST TEST "" "" ""
339 .SH NAME
340 Definition List Test \\- \n\
341 '''+indend_macros+
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.
356 .'''],
360 if __name__ == '__main__':
361 import unittest
362 unittest.main(defaultTest='suite')