1
# Copyright (C) 2010, 2011 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 import tests
20
from bzrlib.tests import (
21
doc_generate as test_dg, # Avoid clash with from bzrlib import doc_generate
25
class TestTextGeneration(test_dg.TestSphinx):
27
def test_special_chars(self):
28
self.create_content("A '@' a '{' and a '}'")
29
self.assertContent("A '@@' a '@{' and a '@}'")
31
def test_emphasis(self):
32
self.create_content('*important*')
33
self.assertContent('@emph{important}')
35
def test_strong(self):
36
self.create_content('**very important**')
37
self.assertContent('@strong{very important}')
39
def test_literal(self):
40
self.create_content('the command is ``foo``')
41
self.assertContent('the command is @code{foo}')
43
def test_paragraphs(self):
44
self.create_content('''\
49
self.assertContent('''\
52
This is another one.''')
54
def test_literal_block(self):
55
self.create_content('''\
61
self.assertContent('''\
70
def test_block_quote(self):
71
self.create_content('''\
72
This is an ordinary paragraph, introducing a block quote.
74
"It is my business to know things. That is my trade."
76
This is another ordinary paragraph.
78
self.assertContent('''\
79
This is an ordinary paragraph, introducing a block quote.
82
"It is my business to know things. That is my trade."
86
This is another ordinary paragraph.
89
# examples are not followed by an empty line
93
class TestDocumentAttributesGeneration(test_dg.TestSphinx):
96
self.create_content('''\
101
self.assertContent('''\
102
@node bazaar-release-notes
103
@chapter Bazaar Release Notes
108
class TestListGeneration(test_dg.TestSphinx):
110
def test_bullet_list(self):
111
self.create_content('''\
112
* This is a bulleted list.
113
* It has two items, the second
116
self.assertContent('''\
119
This is a bulleted list.
122
It has two items, the second
129
def test_enumerated_list(self):
130
self.create_content('''\
131
#. This is a numbered list.
132
#. It has two items, the second
135
self.assertContent('''\
138
This is a numbered list.
141
It has two items, the second
149
class TestTableGeneration(test_dg.TestSphinx):
151
def test_table(self):
152
self.create_content('''\
153
=========== ================
155
=========== ================
159
=========== ================
161
# FIXME: Sphinx bug ? Why are tables enclosed in a block_quote
162
# (translated as an @example).
163
self.assertContent('''\
165
@multitable {xxxxxxxxxxx}{xxxxxxxxxxxxxxxx}
166
@headitem Prefix @tab Description
177
class TestTocTreeGeneration(test_dg.TestSphinx):
179
def test_toctree(self):
180
self.build_tree_contents(
188
bzr 0.0.8 <bzr-0.0.8>
190
('bzr-0.0.8.txt', """
198
* Adding a file whose parent directory is not versioned will
199
implicitly add the parent, and so on up to the root.
202
app, out, err = self.make_sphinx()
204
self.assertFileEqual("""\
205
This file has been converted using a beta rst->texinfo converter.
206
Most of the info links are currently bogus, don't report bugs about them,
207
this is currently worked on.
210
@node table-of-contents
211
@chapter Table of Contents
213
* bzr 0.0.8: (bzr-0.0.8.info)bzr 0.0.8.
217
self.assertFileEqual("""\
218
This file has been converted using a beta rst->texinfo converter.
219
Most of the info links are currently bogus, don't report bugs about them,
220
this is currently worked on.
226
@section Improvements
229
Adding a file whose parent directory is not versioned will
230
implicitly add the parent, and so on up to the root.
236
def test_toctree_empty(self):
237
self.build_tree_contents(
245
app, out, err = self.make_sphinx()
247
self.assertFileEqual("""\
248
This file has been converted using a beta rst->texinfo converter.
249
Most of the info links are currently bogus, don't report bugs about them,
250
this is currently worked on.
253
@node table-of-contents
254
@chapter Table of Contents
259
class TestSections(test_dg.TestSphinx):
261
def test_sections(self):
262
self.create_content('''\
267
Chapter introduction.
279
The first subsection.
284
The second subsection.
289
Here is sus sub section one.
294
Far tooo deep to get a name
299
No idea how to call that, but sphinx says it's a paragraph.
301
self.assertContent('''\
304
Chapter introduction.
311
@subsection subsection one
312
The first subsection.
315
@subsection subsection two
316
The second subsection.
318
@node subsubsection-one
319
@subsubsection subsubsection one
320
Here is sus sub section one.
324
Far tooo deep to get a name
328
No idea how to call that, but sphinx says it's a paragraph.''')
331
class TestReferences(test_dg.TestSphinx):
333
def test_external_reference(self):
334
self.create_content('''\
335
The `example web site`_ is nice.
337
.. _example web site: http://www.example.com/
339
self.assertContent('''\
340
The @uref{http://www.example.com/,example web site} is nice.''')
343
def test_internal_reference(self):
344
self.create_content('''\
345
The `example web site`_ contains more examples.
350
Here we have a lot of nice examples.
353
self.assertContent('''\
354
The example web site (@pxref{example-web-site}) contains more examples.
356
@node example-web-site
357
@chapter Example web site
358
Here we have a lot of nice examples.''')