~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/doc_generate/writers/test_texinfo.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-15 09:21:49 UTC
  • mfrom: (6606.2.1 autodoc-unicode)
  • Revision ID: pqm@pqm.ubuntu.com-20160115092149-z5f4sfq3jvaz0enb
(vila) Fix autodoc runner when LANG=C. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
"""sphinx texinfo writer tests."""
18
 
 
19
 
from bzrlib.tests import (
20
 
    doc_generate as test_dg, # Avoid clash with from bzrlib import doc_generate
21
 
    )
22
 
 
23
 
 
24
 
class TestTextGeneration(test_dg.TestSphinx):
25
 
 
26
 
    def test_special_chars(self):
27
 
        self.create_content("A '@' a '{' and a '}'")
28
 
        self.assertContent("A '@@' a '@{' and a '@}'")
29
 
 
30
 
    def test_emphasis(self):
31
 
        self.create_content('*important*')
32
 
        self.assertContent('@emph{important}')
33
 
 
34
 
    def test_strong(self):
35
 
        self.create_content('**very important**')
36
 
        self.assertContent('@strong{very important}')
37
 
 
38
 
    def test_literal(self):
39
 
        self.create_content('the command is ``foo``')
40
 
        self.assertContent('the command is @code{foo}')
41
 
 
42
 
    def test_paragraphs(self):
43
 
        self.create_content('''\
44
 
This is a paragraph.
45
 
 
46
 
This is another one.
47
 
''')
48
 
        self.assertContent('''\
49
 
This is a paragraph.
50
 
 
51
 
This is another one.''')
52
 
 
53
 
    def test_literal_block(self):
54
 
        self.create_content('''\
55
 
Do this::
56
 
 
57
 
   bzr xxx
58
 
   bzr yyy
59
 
''')
60
 
        self.assertContent('''\
61
 
Do this:
62
 
 
63
 
@samp{bzr xxx
64
 
bzr yyy}
65
 
 
66
 
''',
67
 
                           end='')
68
 
 
69
 
    def test_block_quote(self):
70
 
        self.create_content('''\
71
 
This is an ordinary paragraph, introducing a block quote.
72
 
 
73
 
    "It is my business to know things.  That is my trade."
74
 
 
75
 
This is another ordinary paragraph.
76
 
''')
77
 
        self.assertContent('''\
78
 
This is an ordinary paragraph, introducing a block quote.
79
 
 
80
 
@example
81
 
"It is my business to know things.  That is my trade."
82
 
 
83
 
@end example
84
 
 
85
 
This is another ordinary paragraph.
86
 
 
87
 
''',
88
 
                           # examples are not followed by an empty line
89
 
                           end='')
90
 
 
91
 
 
92
 
class TestDocumentAttributesGeneration(test_dg.TestSphinx):
93
 
 
94
 
    def test_title(self):
95
 
        self.create_content('''\
96
 
####################
97
 
Bazaar Release Notes
98
 
####################
99
 
''')
100
 
        self.assertContent('''\
101
 
@node bazaar-release-notes
102
 
@chapter Bazaar Release Notes
103
 
''',
104
 
                           end='')
105
 
 
106
 
 
107
 
class TestListGeneration(test_dg.TestSphinx):
108
 
 
109
 
    def test_bullet_list(self):
110
 
        self.create_content('''\
111
 
* This is a bulleted list.
112
 
* It has two items, the second
113
 
  item uses two lines.
114
 
''')
115
 
        self.assertContent('''\
116
 
@itemize @bullet
117
 
@item
118
 
This is a bulleted list.
119
 
 
120
 
@item
121
 
It has two items, the second
122
 
item uses two lines.
123
 
 
124
 
@end itemize
125
 
''',
126
 
                           end='')
127
 
 
128
 
    def test_enumerated_list(self):
129
 
        self.create_content('''\
130
 
#. This is a numbered list.
131
 
#. It has two items, the second
132
 
   item uses two lines.
133
 
''')
134
 
        self.assertContent('''\
135
 
@enumerate
136
 
@item
137
 
This is a numbered list.
138
 
 
139
 
@item
140
 
It has two items, the second
141
 
item uses two lines.
142
 
 
143
 
@end enumerate
144
 
''',
145
 
                           end='')
146
 
 
147
 
 
148
 
class TestTableGeneration(test_dg.TestSphinx):
149
 
 
150
 
    def test_table(self):
151
 
        self.create_content('''\
152
 
  ===========         ================
153
 
  Prefix              Description
154
 
  ===========         ================
155
 
  first               The first
156
 
  second              The second
157
 
  last                The last
158
 
  ===========         ================
159
 
''')
160
 
        # FIXME: Sphinx bug ? Why are tables enclosed in a block_quote
161
 
        # (translated as an @example).
162
 
        self.assertContent('''\
163
 
@example
164
 
@multitable {xxxxxxxxxxx}{xxxxxxxxxxxxxxxx}
165
 
@headitem Prefix @tab Description
166
 
@item first
167
 
@tab The first
168
 
@item second
169
 
@tab The second
170
 
@item last
171
 
@tab The last
172
 
@end multitable
173
 
@end example''')
174
 
 
175
 
 
176
 
class TestTocTreeGeneration(test_dg.TestSphinx):
177
 
 
178
 
    def test_toctree(self):
179
 
        self.build_tree_contents(
180
 
            [('index.txt', """
181
 
Table of Contents
182
 
=================
183
 
 
184
 
.. toctree::
185
 
   :maxdepth: 1
186
 
 
187
 
   bzr 0.0.8 <bzr-0.0.8>
188
 
"""),
189
 
             ('bzr-0.0.8.txt', """
190
 
 
191
 
bzr 0.0.8
192
 
*********
193
 
 
194
 
Improvements
195
 
============
196
 
 
197
 
* Adding a file whose parent directory is not versioned will
198
 
  implicitly add the parent, and so on up to the root.
199
 
"""),
200
 
             ])
201
 
        app, out, err = self.make_sphinx()
202
 
        self.build(app)
203
 
        self.assertFileEqual("""\
204
 
This file has been converted using a beta rst->texinfo converter. 
205
 
Most of the info links are currently bogus, don't report bugs about them,
206
 
this is currently worked on.
207
 
@node Top
208
 
@top Placeholder
209
 
@node table-of-contents
210
 
@chapter Table of Contents
211
 
@menu
212
 
* bzr 0.0.8: (bzr-0.0.8.info)bzr 0.0.8. 
213
 
@end menu
214
 
""",
215
 
                             'index.texi')
216
 
        self.assertFileEqual("""\
217
 
This file has been converted using a beta rst->texinfo converter. 
218
 
Most of the info links are currently bogus, don't report bugs about them,
219
 
this is currently worked on.
220
 
@node Top
221
 
@top Placeholder
222
 
@node bzr-0-0-8
223
 
@chapter bzr 0.0.8
224
 
@node improvements
225
 
@section Improvements
226
 
@itemize @bullet
227
 
@item
228
 
Adding a file whose parent directory is not versioned will
229
 
implicitly add the parent, and so on up to the root.
230
 
 
231
 
@end itemize
232
 
""",
233
 
                             'bzr-0.0.8.texi')
234
 
 
235
 
class TestSections(test_dg.TestSphinx):
236
 
 
237
 
    def test_sections(self):
238
 
        self.create_content('''\
239
 
###########
240
 
Chapter one
241
 
###########
242
 
 
243
 
Chapter introduction.
244
 
 
245
 
***********
246
 
section one
247
 
***********
248
 
 
249
 
The first section.
250
 
 
251
 
 
252
 
subsection one
253
 
==============
254
 
 
255
 
The first subsection.
256
 
 
257
 
subsection two
258
 
==============
259
 
 
260
 
The second subsection.
261
 
 
262
 
subsubsection one
263
 
-----------------
264
 
 
265
 
Here is sus sub section one.
266
 
 
267
 
blob one
268
 
^^^^^^^^
269
 
 
270
 
Far tooo deep to get a name
271
 
 
272
 
thing one
273
 
"""""""""
274
 
 
275
 
No idea how to call that, but sphinx says it's a paragraph.
276
 
''')
277
 
        self.assertContent('''\
278
 
@node chapter-one
279
 
@chapter Chapter one
280
 
Chapter introduction.
281
 
 
282
 
@node section-one
283
 
@section section one
284
 
The first section.
285
 
 
286
 
@node subsection-one
287
 
@subsection subsection one
288
 
The first subsection.
289
 
 
290
 
@node subsection-two
291
 
@subsection subsection two
292
 
The second subsection.
293
 
 
294
 
@node subsubsection-one
295
 
@subsubsection subsubsection one
296
 
Here is sus sub section one.
297
 
 
298
 
@node blob-one
299
 
@heading blob one
300
 
Far tooo deep to get a name
301
 
 
302
 
@node thing-one
303
 
@heading thing one
304
 
No idea how to call that, but sphinx says it's a paragraph.''')
305
 
 
306
 
 
307
 
class TestReferences(test_dg.TestSphinx):
308
 
 
309
 
    def test_external_reference(self):
310
 
        self.create_content('''\
311
 
The `example web site`_ is nice.
312
 
 
313
 
.. _example web site: http://www.example.com/
314
 
''')
315
 
        self.assertContent('''\
316
 
The @uref{http://www.example.com/,example web site} is nice.''')
317
 
 
318
 
 
319
 
    def test_internal_reference(self):
320
 
        self.create_content('''\
321
 
The `example web site`_ contains more examples.
322
 
 
323
 
Example web site
324
 
----------------
325
 
 
326
 
Here we have a lot of nice examples.
327
 
 
328
 
''')
329
 
        self.assertContent('''\
330
 
The example web site (@pxref{example-web-site}) contains more examples.
331
 
 
332
 
@node example-web-site
333
 
@chapter Example web site
334
 
Here we have a lot of nice examples.''')
335