~ubuntu-branches/ubuntu/quantal/python-docutils/quantal

« back to all changes in this revision

Viewing changes to test/test_writers/test_manpage.py

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk
  • Date: 2009-12-13 19:54:12 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091213195412-9o7q348lfkucx01f
* Unconditionally recommend python-lxml, as it is used by
  /usr/bin/rst2odt_prepstyles (closes: #560330).
* Demote dependency on an ElementTree implementation to recommendation, as it
  is only used by /usr/bin/rst2odt; remove python-lxml from alternatives, as
  it is never used by the script (closes: #560328).
* Fix insecure use of temporary files in the Emacs major mode for
  reStructuredText (closes: #560755). Thanks to Kumar Appaiah for helping to
  deal with this bug.
* Register docutils documentation using doc-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
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.
 
6
 
 
7
"""
 
8
Tests for manpage writer.
 
9
"""
 
10
 
 
11
from __init__ import DocutilsTestSupport
 
12
 
 
13
from docutils._compat import b
 
14
 
 
15
def suite():
 
16
    settings = {}
 
17
    s = DocutilsTestSupport.PublishTestSuite('manpage', suite_settings=settings)
 
18
    s.generateTests(totest)
 
19
    return s
 
20
 
 
21
indend_macros = r""".
 
22
.nr rst2man-indent-level 0
 
23
.
 
24
.de1 rstReportMargin
 
25
\\$1 \\n[an-margin]
 
26
level \\n[rst2man-indent-level]
 
27
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
 
28
-
 
29
\\n[rst2man-indent0]
 
30
\\n[rst2man-indent1]
 
31
\\n[rst2man-indent2]
 
32
..
 
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:
 
39
..
 
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
 
47
..
 
48
"""
 
49
 
 
50
totest = {}
 
51
 
 
52
totest['blank'] = [
 
53
        ["", 
 
54
        r""".TH   "" "" ""
 
55
.SH NAME
 
56
 \- 
 
57
.\" Man page generated from reStructeredText.
 
58
.
 
59
.\" Generated by docutils manpage writer.
 
60
.\" 
 
61
.
 
62
"""],
 
63
    ]
 
64
 
 
65
totest['simple'] = [
 
66
        ["""\
 
67
========        
 
68
 simple
 
69
========
 
70
 
 
71
---------------
 
72
 The way to go
 
73
---------------
 
74
 
 
75
:Author: someone@somewhere.net
 
76
:Date:   2009-08-05
 
77
:Copyright: public domain
 
78
:Version: 0.1
 
79
:Manual section: 1
 
80
:Manual group: text processing
 
81
:Arbitrary field: some text
 
82
 
 
83
SYNOPSIS
 
84
========
 
85
 
 
86
::
 
87
 
 
88
  K.I.S.S keep it simple.
 
89
 
 
90
DESCRIPTION
 
91
===========
 
92
 
 
93
General rule of life.
 
94
 
 
95
OPTIONS
 
96
=======
 
97
 
 
98
--config=<file>         Read configuration settings from <file>, if it exists.
 
99
--version, -V           Show this program's version number and exit.
 
100
--help, -h              Show this help message and exit.
 
101
 
 
102
 
 
103
""", 
 
104
        r""".\" Man page generated from reStructeredText.
 
105
.
 
106
.TH SIMPLE 1 "2009-08-05" "0.1" "text processing"
 
107
.SH NAME
 
108
simple \- The way to go
 
109
"""+indend_macros+
 
110
r""".SH SYNOPSIS
 
111
.sp
 
112
.nf
 
113
.ft C
 
114
K.I.S.S keep it simple.
 
115
.ft P
 
116
.fi
 
117
.SH DESCRIPTION
 
118
.sp
 
119
General rule of life.
 
120
.SH OPTIONS
 
121
.INDENT 0.0
 
122
.TP
 
123
.BI \-\-config\fB= <file>
 
124
.
 
125
Read configuration settings from <file>, if it exists.
 
126
.TP
 
127
.B \-\-version,  \-V
 
128
.
 
129
Show this program\(aqs version number and exit.
 
130
.TP
 
131
.B \-\-help,  \-h
 
132
.
 
133
Show this help message and exit.
 
134
.UNINDENT
 
135
.SH AUTHOR
 
136
someone@somewhere.net
 
137
 
 
138
Arbitrary field: some text
 
139
.SH COPYRIGHT
 
140
public domain
 
141
.\" Generated by docutils manpage writer.
 
142
.\" 
 
143
.
 
144
"""],
 
145
    ]
 
146
 
 
147
totest['table'] = [
 
148
        ["""\
 
149
        ====== =====
 
150
         head   and
 
151
        ====== =====
 
152
           1     2
 
153
          abc   so
 
154
        ====== =====
 
155
""", 
 
156
'''\
 
157
.TH   "" "" ""
 
158
.SH NAME
 
159
 \\- \n\
 
160
.\\" Man page generated from reStructeredText.
 
161
.
 
162
.INDENT 0.0
 
163
.INDENT 3.5
 
164
.TS
 
165
center;
 
166
|l|l|.
 
167
_
 
168
T{
 
169
head
 
170
T}\tT{
 
171
and
 
172
T}
 
173
_
 
174
T{
 
175
1
 
176
T}\tT{
 
177
2
 
178
T}
 
179
_
 
180
T{
 
181
abc
 
182
T}\tT{
 
183
so
 
184
T}
 
185
_
 
186
.TE
 
187
.UNINDENT
 
188
.UNINDENT
 
189
.\\" Generated by docutils manpage writer.
 
190
.\\" 
 
191
.
 
192
''']
 
193
]
 
194
 
 
195
if __name__ == '__main__':
 
196
    import unittest
 
197
    unittest.main(defaultTest='suite')