Do not emit comment line with trailng blank
[docutils.git] / test / test_writers / test_manpage.py
blobb0ed942a5224eda4353a725f48a7a034bb9d60a3
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 reStructeredText.
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.
105 """,
106 r""".\" Man page generated from reStructeredText.
108 .TH SIMPLE 1 "2009-08-05" "0.1" "text processing"
109 .SH NAME
110 simple \- The way to go
111 """+indend_macros+
112 r""".SH SYNOPSIS
115 .ft C
116 K.I.S.S keep it simple.
117 .ft P
119 .SH DESCRIPTION
121 General rule of life.
122 .SH OPTIONS
123 .INDENT 0.0
125 .BI \-\-config\fB= <file>
126 Read configuration settings from <file>, if it exists.
128 .B \-\-version, \-V
129 Show this program\(aqs version number and exit.
131 .B \-\-help, \-h
132 Show this help message and exit.
133 .UNINDENT
134 .SH OTHER SECTION
136 With mixed case.
137 .SH AUTHOR
138 someone@somewhere.net
140 Arbitrary field: some text
141 .SH COPYRIGHT
142 public domain
143 .\" Generated by docutils manpage writer.
145 """],
148 totest['table'] = [
149 ["""\
150 ====== =====
151 head and
152 ====== =====
154 abc so
155 ====== =====
156 """,
157 '''\
158 .TH "" "" ""
159 .SH NAME
160 \\- \n\
161 .\\" Man page generated from reStructeredText.
163 .INDENT 0.0
164 .INDENT 3.5
166 center;
167 |l|l|.
170 head
171 T}\tT{
177 T}\tT{
183 T}\tT{
188 .UNINDENT
189 .UNINDENT
190 .\\" Generated by docutils manpage writer.
192 ''']
195 totest['optiongroup'] = [
196 ["""
197 optin group with dot as group item
200 bla bla bla
203 bla bla bla
206 bla bla bla
209 bla bla bla
212 bla bla bla
213 """,
214 """\
215 .TH "" "" ""
216 .SH NAME
217 \\- \n\
218 .\\" Man page generated from reStructeredText.
220 optin group with dot as group item
221 .INDENT 0.0
223 .B $
224 bla bla bla
225 .UNINDENT
226 .INDENT 0.0
228 .B #
229 bla bla bla
230 .UNINDENT
231 .INDENT 0.0
233 .B .
234 bla bla bla
235 .UNINDENT
236 .INDENT 0.0
238 .B [
239 bla bla bla
240 .UNINDENT
241 .INDENT 0.0
243 .B ]
244 bla bla bla
245 .UNINDENT
246 .\\" Generated by docutils manpage writer.
247 ."""],
250 totest['definitionlist'] = [
251 ["""
252 ====================
253 Definition List Test
254 ====================
256 :Abstract: Docinfo is required.
258 Section
259 =======
261 :term1:
263 Description of Term 1 Description of Term 1 Description of Term 1
264 Description of Term 1 Description of Term 1
266 Description of Term 1 Description of Term 1 Description of Term 1
267 Description of Term 1 Description of Term 1
269 """,
270 '''\
271 .TH DEFINITION LIST TEST "" "" ""
272 .SH NAME
273 Definition List Test \\- \n\
274 .\\" Man page generated from reStructeredText.
276 .SS Abstract
278 Docinfo is required.
279 .SH SECTION
280 .INDENT 0.0
282 .B term1
283 Description of Term 1 Description of Term 1 Description of Term 1
284 Description of Term 1 Description of Term 1
286 Description of Term 1 Description of Term 1 Description of Term 1
287 Description of Term 1 Description of Term 1
288 .UNINDENT
289 .\\" Generated by docutils manpage writer.
290 .'''],
294 if __name__ == '__main__':
295 import unittest
296 unittest.main(defaultTest='suite')