4 # Author: Guenter Milde
5 # Copyright: This module has been placed in the public domain.
8 Test the 'code' directive in parsers/rst/directives/body.py.
11 from __init__
import DocutilsTestSupport
12 from docutils
.utils
.code_analyzer
import with_pygments
15 s
= DocutilsTestSupport
.ParserTestSuite()
17 del(totest
['code-parsing'])
18 s
.generateTests(totest
)
30 <document source="test data">
31 <literal_block classes="code" xml:space="preserve">
37 :name: without argument
39 This is a code block with generic options.
42 <document source="test data">
43 <literal_block classes="code testclass" ids="without-argument" names="without\ argument" xml:space="preserve">
44 This is a code block with generic options.
50 This is a code block with text.
53 <document source="test data">
54 <literal_block classes="code text testclass" xml:space="preserve">
55 This is a code block with text.
61 This is a code block with text.
64 <document source="test data">
65 <literal_block classes="code" xml:space="preserve">
68 This is a code block with text.
74 This is a code block with text.
77 <document source="test data">
78 <literal_block classes="code" xml:space="preserve">
81 This is a code block with text.
87 <document source="test data">
88 <system_message level="3" line="1" source="test data" type="ERROR">
90 Content block expected for the "code" directive; none found.
91 <literal_block xml:space="preserve">
96 totest
['code-parsing'] = [
101 print 'hello world' # to stdout
104 <document source="test data">
105 <literal_block classes="code python testclass" xml:space="preserve">
107 <inline classes="keyword">
110 <inline classes="literal string">
113 <inline classes="comment">
126 # and now for something completely different
130 <document source="test data">
131 <literal_block classes="code python testclass" ids="my-function" names="my_function" xml:space="preserve">
132 <inline classes="ln">
134 <inline classes="keyword">
137 <inline classes="name function">
139 <inline classes="punctuation">
142 <inline classes="ln">
145 <inline classes="literal string doc">
146 \'\'\'Test the lexer.
147 <inline classes="ln">
149 <inline classes="literal string doc">
152 <inline classes="ln">
155 <inline classes="ln">
158 <inline classes="comment">
159 # and now for something completely different
161 <inline classes="ln">
164 <inline classes="keyword">
167 <inline classes="literal number integer">
169 <inline classes="operator">
171 <inline classes="literal number integer">
178 hello \emph{world} % emphasize
181 <document source="test data">
182 <literal_block classes="code latex testclass" xml:space="preserve">
184 <inline classes="keyword">
186 <inline classes="name builtin">
189 <inline classes="name builtin">
192 <inline classes="comment">
198 This is a code block with text.
201 <document source="test data">
202 <literal_block classes="code rst" xml:space="preserve">
203 <inline classes="ln">
205 This is a code block with text.
211 autoload("abc_mode", "abc");
214 <document source="test data">
215 <system_message level="2" line="1" source="test data" type="WARNING">
217 Cannot analyze code. No Pygments lexer found for "s-lang".
218 <literal_block xml:space="preserve">
222 autoload("abc_mode", "abc");
225 Place the language name in a class argument to avoid the no-lexer warning:
231 autoload("abc_mode", "abc");
234 <document source="test data">
236 Place the language name in a class argument to avoid the no-lexer warning:
237 <literal_block classes="code s-lang" xml:space="preserve">
239 autoload("abc_mode", "abc");
244 if __name__
== '__main__':
246 unittest
.main(defaultTest
='suite')