4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
11 from __init__
import DocutilsTestSupport
14 s
= DocutilsTestSupport
.ParserTestSuite()
15 s
.generateTests(totest
)
24 (Internal hyperlink target.)
27 <document source="test data">
28 <target ids="target" names="target">
30 (Internal hyperlink target.)
33 .. _optional space before colon :
36 <document source="test data">
37 <target ids="optional-space-before-colon" names="optional\ space\ before\ colon">
40 External hyperlink targets:
42 .. _one-liner: http://structuredtext.sourceforge.net
44 .. _starts-on-this-line: http://
49 http://structuredtext.
52 .. _not-indirect: uri\\_
55 <document source="test data">
57 External hyperlink targets:
58 <target ids="one-liner" names="one-liner" refuri="http://structuredtext.sourceforge.net">
59 <target ids="starts-on-this-line" names="starts-on-this-line" refuri="http://structuredtext.sourceforge.net">
60 <target ids="entirely-below" names="entirely-below" refuri="http://structuredtext.sourceforge.net">
61 <target ids="not-indirect" names="not-indirect" refuri="uri_">
64 Indirect hyperlink targets:
66 .. _target1: reference_
68 .. _target2: `phrase-link reference`_
71 <document source="test data">
73 Indirect hyperlink targets:
74 <target ids="target1" names="target1" refname="reference">
75 <target ids="target2" names="target2" refname="phrase-link reference">
78 .. _a long target name:
80 .. _`a target name: including a colon (quoted)`:
82 .. _a target name\: including a colon (escaped):
85 <document source="test data">
86 <target ids="a-long-target-name" names="a\ long\ target\ name">
87 <target ids="a-target-name-including-a-colon-quoted" names="a\ target\ name:\ including\ a\ colon\ (quoted)">
88 <target ids="a-target-name-including-a-colon-escaped" names="a\ target\ name:\ including\ a\ colon\ (escaped)">
91 .. _`target: No matching backquote.
92 .. _`: No matching backquote either.
95 <document source="test data">
96 <comment xml:space="preserve">
97 _`target: No matching backquote.
98 <system_message level="2" line="1" source="test data" type="WARNING">
100 malformed hyperlink target.
101 <comment xml:space="preserve">
102 _`: No matching backquote either.
103 <system_message level="2" line="2" source="test data" type="WARNING">
105 malformed hyperlink target.
108 .. _a very long target name,
114 <document source="test data">
115 <target ids="a-very-long-target-name-split-across-lines" names="a\ very\ long\ target\ name,\ split\ across\ lines">
116 <target ids="and-another-with-backquotes" names="and\ another,\ with\ backquotes">
121 .. _target: http://www.python.org/
124 <document source="test data">
127 <target ids="target" names="target" refuri="http://www.python.org/">
130 .. _email: jdoe@example.com
132 .. _multi-line email: jdoe
136 <document source="test data">
137 <target ids="email" names="email" refuri="mailto:jdoe@example.com">
138 <target ids="multi-line-email" names="multi-line\ email" refuri="mailto:jdoe@example.com">
143 .. __malformed: no good
145 Target beginning with an underscore:
150 <document source="test data">
153 <comment xml:space="preserve">
155 <system_message level="2" line="3" source="test data" type="WARNING">
157 malformed hyperlink target.
159 Target beginning with an underscore:
160 <target ids="target" names="_target" refuri="OK">
163 Duplicate external targets (different URIs):
170 <document source="test data">
172 Duplicate external targets (different URIs):
173 <target dupnames="target" ids="target" refuri="first">
174 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
176 Duplicate explicit target name: "target".
177 <target dupnames="target" ids="id1" refuri="second">
180 Duplicate external targets (same URIs):
187 <document source="test data">
189 Duplicate external targets (same URIs):
190 <target ids="target" names="target" refuri="first">
191 <system_message backrefs="id1" level="1" line="5" source="test data" type="INFO">
193 Duplicate explicit target name: "target".
194 <target dupnames="target" ids="id1" refuri="first">
197 Duplicate implicit targets.
210 <document source="test data">
212 Duplicate implicit targets.
213 <section dupnames="title" ids="title">
218 <section dupnames="title" ids="id1">
221 <system_message backrefs="id1" level="1" line="9" source="test data" type="INFO">
223 Duplicate implicit target name: "title".
228 Duplicate implicit/explicit targets.
238 <document source="test data">
240 Duplicate implicit/explicit targets.
241 <section dupnames="title" ids="title">
244 <system_message backrefs="id1" level="1" line="6" source="test data" type="INFO">
246 Duplicate implicit target name: "title".
247 <target ids="id1" names="title">
252 Duplicate implicit/directive targets.
261 <document source="test data">
263 Duplicate implicit/directive targets.
264 <section dupnames="title" ids="title">
267 <pending ids="id1" names="title">
268 <system_message backrefs="id1" level="1" line="4" source="test data" type="INFO">
270 Duplicate implicit target name: "title".
271 .. internal attributes:
272 .transform: docutils.transforms.references.TargetNotes
276 Duplicate explicit targets.
291 <document source="test data">
293 Duplicate explicit targets.
294 <target dupnames="title" ids="title">
297 <system_message backrefs="id1" level="2" line="7" source="test data" type="WARNING">
299 Duplicate explicit target name: "title".
300 <target dupnames="title" ids="id1">
303 <system_message backrefs="id2" level="2" line="11" source="test data" type="WARNING">
305 Duplicate explicit target name: "title".
306 <target dupnames="title" ids="id2">
311 Duplicate explicit/directive targets.
317 .. rubric:: this is a title too
322 <document source="test data">
324 Duplicate explicit/directive targets.
325 <target dupnames="title" ids="title">
328 <rubric dupnames="title" ids="id1">
330 <system_message backrefs="id1" level="2" line="9" source="test data" type="WARNING">
332 Duplicate explicit target name: "title".
340 Implicit section header target.
342 .. [TARGET] Citation target.
344 .. [#target] Autonumber-labeled footnote target.
348 Explicit internal target.
350 .. _target: Explicit_external_target
352 .. rubric:: directive with target
356 <document source="test data">
359 <section dupnames="target" ids="target">
363 Implicit section header target.
364 <citation dupnames="target" ids="id1">
367 <system_message backrefs="id1" level="1" line="8" source="test data" type="INFO">
369 Duplicate implicit target name: "target".
372 <footnote auto="1" dupnames="target" ids="id2">
373 <system_message backrefs="id2" level="2" line="10" source="test data" type="WARNING">
375 Duplicate explicit target name: "target".
377 Autonumber-labeled footnote target.
378 <system_message backrefs="id3" level="2" line="12" source="test data" type="WARNING">
380 Duplicate explicit target name: "target".
381 <target dupnames="target" ids="id3">
383 Explicit internal target.
384 <system_message backrefs="id4" level="2" line="16" source="test data" type="WARNING">
386 Duplicate explicit target name: "target".
387 <target dupnames="target" ids="id4" refuri="Explicit_external_target">
388 <rubric dupnames="target" ids="id5">
389 directive with target
390 <system_message backrefs="id5" level="2" line="4" source="test data" type="WARNING">
392 Duplicate explicit target name: "target".
395 .. _unescaped colon at end:: no good
397 .. _:: no good either
399 .. _escaped colon\:: OK
401 .. _`unescaped colon, quoted:`: OK
404 <document source="test data">
405 <comment xml:space="preserve">
406 _unescaped colon at end:: no good
407 <system_message level="2" line="1" source="test data" type="WARNING">
409 malformed hyperlink target.
410 <comment xml:space="preserve">
412 <system_message level="2" line="3" source="test data" type="WARNING">
414 malformed hyperlink target.
415 <target ids="escaped-colon" names="escaped\ colon:" refuri="OK">
416 <target ids="unescaped-colon-quoted" names="unescaped\ colon,\ quoted:" refuri="OK">
420 totest
['anonymous_targets'] = [
422 Anonymous external hyperlink target:
424 .. __: http://w3c.org/
427 <document source="test data">
429 Anonymous external hyperlink target:
430 <target anonymous="1" ids="id1" refuri="http://w3c.org/">
433 Anonymous external hyperlink target:
438 <document source="test data">
440 Anonymous external hyperlink target:
441 <target anonymous="1" ids="id1" refuri="http://w3c.org/">
444 Anonymous indirect hyperlink target:
449 <document source="test data">
451 Anonymous indirect hyperlink target:
452 <target anonymous="1" ids="id1" refname="reference">
455 Anonymous external hyperlink target, not indirect:
459 __ this URI ends with an underscore_
462 <document source="test data">
464 Anonymous external hyperlink target, not indirect:
465 <target anonymous="1" ids="id1" refuri="uri_">
466 <target anonymous="1" ids="id2" refuri="thisURIendswithanunderscore_">
469 Anonymous indirect hyperlink targets:
476 <document source="test data">
478 Anonymous indirect hyperlink targets:
479 <target anonymous="1" ids="id1" refname="reference">
480 <target anonymous="1" ids="id2" refname="a very long reference">
483 Mixed anonymous & named indirect hyperlink targets:
488 .. _target1: reference_
491 .. _target2: reference_
498 <document source="test data">
500 Mixed anonymous & named indirect hyperlink targets:
501 <target anonymous="1" ids="id1" refname="reference">
502 <target anonymous="1" ids="id2" refname="reference">
503 <target anonymous="1" ids="id3" refname="reference">
504 <target ids="target1" names="target1" refname="reference">
505 <system_message level="2" line="7" source="test data" type="WARNING">
507 Explicit markup ends without a blank line; unexpected unindent.
510 <target ids="target2" names="target2" refname="reference">
511 <target anonymous="1" ids="id4" refname="reference">
512 <target anonymous="1" ids="id5" refname="reference">
513 <target anonymous="1" ids="id6" refname="reference">
514 <system_message level="2" line="13" source="test data" type="WARNING">
516 Explicit markup ends without a blank line; unexpected unindent.
524 <document source="test data">
525 <comment xml:space="preserve">
531 if __name__
== '__main__':
533 unittest
.main(defaultTest
='suite')