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('@chapter Bazaar Release Notes\n', end='')
103
class TestListGeneration(test_dg.TestSphinx):
105
def test_bullet_list(self):
106
self.create_content('''\
107
* This is a bulleted list.
108
* It has two items, the second
111
self.assertContent('''\
114
This is a bulleted list.
117
It has two items, the second
124
def test_enumerated_list(self):
125
self.create_content('''\
126
#. This is a numbered list.
127
#. It has two items, the second
130
self.assertContent('''\
133
This is a numbered list.
136
It has two items, the second
144
class TestTableGeneration(test_dg.TestSphinx):
146
def test_table(self):
147
self.create_content('''\
148
=========== ================
150
=========== ================
154
=========== ================
156
# FIXME: Sphinx bug ? Why are tables enclosed in a block_quote
157
# (translated as an @example).
158
self.assertContent('''\
160
@multitable {xxxxxxxxxxx}{xxxxxxxxxxxxxxxx}
161
@headitem Prefix @tab Description
172
class TestTocTreeGeneration(test_dg.TestSphinx):
174
def test_toctree(self):
175
self.build_tree_contents(
183
bzr 0.0.8 <bzr-0.0.8>
185
('bzr-0.0.8.txt', """
193
* Adding a file whose parent directory is not versioned will
194
implicitly add the parent, and so on up to the root.
197
app, out, err = self.make_sphinx()
199
self.assertFileEqual("""\
200
@chapter Table of Contents
202
* bzr 0.0.8: (bzr-0.0.8.info)bzr 0.0.8.
206
self.assertFileEqual("""\
208
@section Improvements
211
Adding a file whose parent directory is not versioned will
212
implicitly add the parent, and so on up to the root.
218
class TestSections(test_dg.TestSphinx):
220
def test_sections(self):
221
self.create_content('''\
226
Chapter introduction.
238
The first subsection.
243
The second subsection.
248
Here is sus sub section one.
253
Far tooo deep to get a name
258
No idea how to call that, but sphinx says it's a paragraph.
260
self.assertContent('''\
262
Chapter introduction.
267
@subsection subsection one
268
The first subsection.
270
@subsection subsection two
271
The second subsection.
273
@subsubsection subsubsection one
274
Here is sus sub section one.
277
Far tooo deep to get a name
280
No idea how to call that, but sphinx says it's a paragraph.''')