1
# Copyright (C) 2010 Canonical Ltd
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.
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.
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
17
"""sphinx texinfo writer tests."""
19
from bzrlib.tests import (
20
doc_generate as test_dg, # Avoid clash with from bzrlib import doc_generate
24
class TestTextGeneration(test_dg.TestSphinx):
26
def test_special_chars(self):
27
self.create_content("A '@' a '{' and a '}'")
28
self.assertContent("A '@@' a '@{' and a '@}'")
30
def test_emphasis(self):
31
self.create_content('*important*')
32
self.assertContent('@emph{important}')
34
def test_strong(self):
35
self.create_content('**very important**')
36
self.assertContent('@strong{very important}')
38
def test_literal(self):
39
self.create_content('the command is ``foo``')
40
self.assertContent('the command is @code{foo}')
42
def test_paragraphs(self):
43
self.create_content('''\
48
self.assertContent('''\
51
This is another one.''')
53
def test_literal_block(self):
54
self.create_content('''\
60
self.assertContent('''\
69
def test_block_quote(self):
70
self.create_content('''\
71
This is an ordinary paragraph, introducing a block quote.
73
"It is my business to know things. That is my trade."
75
This is another ordinary paragraph.
77
self.assertContent('''\
78
This is an ordinary paragraph, introducing a block quote.
81
"It is my business to know things. That is my trade."
85
This is another ordinary paragraph.
88
# examples are not followed by an empty line
92
class TestDocumentAttributesGeneration(test_dg.TestSphinx):
95
self.create_content('''\
100
self.assertContent('''\
101
@node bazaar-release-notes
102
@chapter Bazaar Release Notes
107
class TestListGeneration(test_dg.TestSphinx):
109
def test_bullet_list(self):
110
self.create_content('''\
111
* This is a bulleted list.
112
* It has two items, the second
115
self.assertContent('''\
118
This is a bulleted list.
121
It has two items, the second
128
def test_enumerated_list(self):
129
self.create_content('''\
130
#. This is a numbered list.
131
#. It has two items, the second
134
self.assertContent('''\
137
This is a numbered list.
140
It has two items, the second
148
class TestTableGeneration(test_dg.TestSphinx):
150
def test_table(self):
151
self.create_content('''\
152
=========== ================
154
=========== ================
158
=========== ================
160
# FIXME: Sphinx bug ? Why are tables enclosed in a block_quote
161
# (translated as an @example).
162
self.assertContent('''\
164
@multitable {xxxxxxxxxxx}{xxxxxxxxxxxxxxxx}
165
@headitem Prefix @tab Description
176
class TestTocTreeGeneration(test_dg.TestSphinx):
178
def test_toctree(self):
179
self.build_tree_contents(
187
bzr 0.0.8 <bzr-0.0.8>
189
('bzr-0.0.8.txt', """
197
* Adding a file whose parent directory is not versioned will
198
implicitly add the parent, and so on up to the root.
201
app, out, err = self.make_sphinx()
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.
209
@node table-of-contents
210
@chapter Table of Contents
212
* bzr 0.0.8: (bzr-0.0.8.info)bzr 0.0.8.
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.
225
@section Improvements
228
Adding a file whose parent directory is not versioned will
229
implicitly add the parent, and so on up to the root.
235
class TestSections(test_dg.TestSphinx):
237
def test_sections(self):
238
self.create_content('''\
243
Chapter introduction.
255
The first subsection.
260
The second subsection.
265
Here is sus sub section one.
270
Far tooo deep to get a name
275
No idea how to call that, but sphinx says it's a paragraph.
277
self.assertContent('''\
280
Chapter introduction.
287
@subsection subsection one
288
The first subsection.
291
@subsection subsection two
292
The second subsection.
294
@node subsubsection-one
295
@subsubsection subsubsection one
296
Here is sus sub section one.
300
Far tooo deep to get a name
304
No idea how to call that, but sphinx says it's a paragraph.''')
307
class TestReferences(test_dg.TestSphinx):
309
def test_external_reference(self):
310
self.create_content('''\
311
The `example web site`_ is nice.
313
.. _example web site: http://www.example.com/
315
self.assertContent('''\
316
The @uref{http://www.example.com/,example web site} is nice.''')
319
def test_internal_reference(self):
320
self.create_content('''\
321
The `example web site`_ contains more examples.
326
Here we have a lot of nice examples.
329
self.assertContent('''\
330
The example web site (@pxref{example-web-site}) contains more examples.
332
@node example-web-site
333
@chapter Example web site
334
Here we have a lot of nice examples.''')