/brz/remove-bazaar

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