1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
#! /usr/bin/env python
# Author: Jon Waltman <jonathan.waltman@gmail.com>
# Copyright: This module has been placed in the public domain.
"""
Tests for Texinfo writer.
"""
import os
import os.path
import sys
import texinfo
sys.path.insert(0, os.path.abspath('../../docutils/test'))
import DocutilsTestSupport
def suite():
settings = {}
s = DocutilsTestSupport.PublishTestSuite('texinfo', suite_settings=settings)
s.generateTests(totest)
return s
template = texinfo.TEMPLATE
parts = dict(
filename='<string>.info',
direntry='',
title='<untitled>',
paragraphindent='2',
exampleindent='4',
preamble='',
body='\n',
)
totest = {}
totest['blank'] = [
# input
["",
## # expected output
template % dict(parts)],
]
totest['escaping'] = [
# input
[r"""
Escaping -- @,{}:
*****************
@commands{ use braces }.
@ { } @@ {{ }}
@} @@}}
@{ @@{{
""",
## # expected output
template % dict(parts,
title='Escaping --',
body=
r"""@@commands@{ use braces @}.
@@ @{ @} @@@@ @{@{ @}@}
@@@} @@@@@}@}
@@@{ @@@@@{@{
""")],
]
totest['table_with_markup'] = [
# input
[r"""
+------------+---------------------+--------------------+
| emphasis | strong emphasis | inline literal |
+============+=====================+====================+
| *emphasis* | **strong emphasis** | ``inline literal`` |
+------------+---------------------+--------------------+
""",
## # expected output
template % dict(parts,
body=
r"""@multitable {xxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
@headitem emphasis
@tab strong emphasis
@tab inline literal
@item @emph{emphasis}
@tab @strong{strong emphasis}
@tab @code{inline literal}
@end multitable
""")],
]
totest['sections'] = [
# input
[r"""
Top
***
This tests sectioning.
Section 1
=========
SubSection 1.1
--------------
SubSubSection 1.1.1
~~~~~~~~~~~~~~~~~~~
Section 2
=========
""",
## # expected output
template % dict(parts,
title='Top',
body=
r"""This tests sectioning.
@menu
* Section 1::
* Section 2::
@detailmenu
--- The Detailed Node Listing ---
Section 1
* SubSection 1 1::
@end detailmenu
@end menu
@node Section 1,Section 2,Top,Top
@anchor{section 1}@anchor{0}@anchor{section-1}
@chapter Section 1
@menu
* SubSection 1 1::
@end menu
@node SubSection 1 1,,,Section 1
@anchor{subsection 1 1}@anchor{1}@anchor{subsection-1-1}
@section SubSection 1.1
@menu
* SubSubSection 1 1 1::
@end menu
@node SubSubSection 1 1 1,,,SubSection 1 1
@anchor{subsubsection 1 1 1}@anchor{2}@anchor{subsubsection-1-1-1}
@subsection SubSubSection 1.1.1
@node Section 2,,Section 1,Top
@anchor{section 2}@anchor{3}@anchor{section-2}
@chapter Section 2
""")],
]
totest['duplicate_sections'] = [
# input
[r"""
Duplicate
=========
Duplicate
=========
Duplicate
=========
""",
## # expected output
template % dict(parts,
title='Duplicate',
body=
r"""@menu
* Duplicate: Duplicate<2>.
* Duplicate: Duplicate<3>.
@end menu
@node Duplicate<2>,Duplicate<3>,Top,Top
@anchor{duplicate<2>}@anchor{0}@anchor{1}@anchor{id1}
@unnumbered Duplicate
@node Duplicate<3>,,Duplicate<2>,Top
@anchor{duplicate<3>}@anchor{2}@anchor{id2}
@unnumbered Duplicate
""")],
]
totest['comments'] = [
# input
[r"""
.. Foo
bar
""",
## # expected output
template % dict(parts,
body=
r"""@c Foo
@c bar
""")],
]
totest['docinfo'] = [
# input
[r"""
Doc Info Test
=============
:Author: Jon
:Copyright: This document has been placed in the public domain.
Example...
""",
## # expected output
template % dict(parts,
title='Doc Info Test',
body=
r"""@itemize @w
@item Author:
Jon
@item Copyright:
This document has been placed in the public domain.
@end itemize
Example...
""")],
]
totest['admonitions'] = [
# input
[r"""
Admonitions
===========
.. Note::
Hooty hoo!
""",
## # expected output
template % dict(parts,
title='Admonitions',
body=
r"""@cartouche
@quotation Note
Hooty hoo!
@end quotation
@end cartouche
""")],
]
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')
|