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 .. _escaped-whitespace: http://example.org/a\ path\ with\
55 .. _not-indirect: uri\_
58 <document source="test data">
60 External hyperlink targets:
61 <target ids="one-liner" names="one-liner" refuri="http://structuredtext.sourceforge.net">
62 <target ids="starts-on-this-line" names="starts-on-this-line" refuri="http://structuredtext.sourceforge.net">
63 <target ids="entirely-below" names="entirely-below" refuri="http://structuredtext.sourceforge.net">
64 <target ids="escaped-whitespace" names="escaped-whitespace" refuri="http://example.org/a path with spaces.html">
65 <target ids="not-indirect" names="not-indirect" refuri="uri_">
68 Indirect hyperlink targets:
70 .. _target1: reference_
72 .. _target2: `phrase-link reference`_
75 <document source="test data">
77 Indirect hyperlink targets:
78 <target ids="target1" names="target1" refname="reference">
79 <target ids="target2" names="target2" refname="phrase-link reference">
82 .. _a long target name:
84 .. _`a target name: including a colon (quoted)`:
86 .. _a target name\: including a colon (escaped):
89 <document source="test data">
90 <target ids="a-long-target-name" names="a\ long\ target\ name">
91 <target ids="a-target-name-including-a-colon-quoted" names="a\ target\ name:\ including\ a\ colon\ (quoted)">
92 <target ids="a-target-name-including-a-colon-escaped" names="a\ target\ name:\ including\ a\ colon\ (escaped)">
95 .. _`target: No matching backquote.
96 .. _`: No matching backquote either.
99 <document source="test data">
100 <comment xml:space="preserve">
101 _`target: No matching backquote.
102 <system_message level="2" line="1" source="test data" type="WARNING">
104 malformed hyperlink target.
105 <comment xml:space="preserve">
106 _`: No matching backquote either.
107 <system_message level="2" line="2" source="test data" type="WARNING">
109 malformed hyperlink target.
112 .. _a very long target name,
118 <document source="test data">
119 <target ids="a-very-long-target-name-split-across-lines" names="a\ very\ long\ target\ name,\ split\ across\ lines">
120 <target ids="and-another-with-backquotes" names="and\ another,\ with\ backquotes">
125 .. _target: http://www.python.org/
128 <document source="test data">
131 <target ids="target" names="target" refuri="http://www.python.org/">
134 .. _email: jdoe@example.com
136 .. _multi-line email: jdoe
140 <document source="test data">
141 <target ids="email" names="email" refuri="mailto:jdoe@example.com">
142 <target ids="multi-line-email" names="multi-line\ email" refuri="mailto:jdoe@example.com">
147 .. __malformed: no good
149 Target beginning with an underscore:
154 <document source="test data">
157 <comment xml:space="preserve">
159 <system_message level="2" line="3" source="test data" type="WARNING">
161 malformed hyperlink target.
163 Target beginning with an underscore:
164 <target ids="target" names="_target" refuri="OK">
167 Duplicate external targets (different URIs):
174 <document source="test data">
176 Duplicate external targets (different URIs):
177 <target dupnames="target" ids="target" refuri="first">
178 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
180 Duplicate explicit target name: "target".
181 <target dupnames="target" ids="id1" refuri="second">
184 Duplicate external targets (same URIs):
191 <document source="test data">
193 Duplicate external targets (same URIs):
194 <target ids="target" names="target" refuri="first">
195 <system_message backrefs="id1" level="1" line="5" source="test data" type="INFO">
197 Duplicate explicit target name: "target".
198 <target dupnames="target" ids="id1" refuri="first">
201 Duplicate implicit targets.
214 <document source="test data">
216 Duplicate implicit targets.
217 <section dupnames="title" ids="title">
222 <section dupnames="title" ids="id1">
225 <system_message backrefs="id1" level="1" line="9" source="test data" type="INFO">
227 Duplicate implicit target name: "title".
232 Duplicate implicit/explicit targets.
242 <document source="test data">
244 Duplicate implicit/explicit targets.
245 <section dupnames="title" ids="title">
248 <system_message backrefs="id1" level="1" line="6" source="test data" type="INFO">
250 Duplicate implicit target name: "title".
251 <target ids="id1" names="title">
256 Duplicate implicit/directive targets.
265 <document source="test data">
267 Duplicate implicit/directive targets.
268 <section dupnames="title" ids="title">
271 <pending ids="id1" names="title">
272 <system_message backrefs="id1" level="1" line="4" source="test data" type="INFO">
274 Duplicate implicit target name: "title".
275 .. internal attributes:
276 .transform: docutils.transforms.references.TargetNotes
280 Duplicate explicit targets.
295 <document source="test data">
297 Duplicate explicit targets.
298 <target dupnames="title" ids="title">
301 <system_message backrefs="id1" level="2" line="7" source="test data" type="WARNING">
303 Duplicate explicit target name: "title".
304 <target dupnames="title" ids="id1">
307 <system_message backrefs="id2" level="2" line="11" source="test data" type="WARNING">
309 Duplicate explicit target name: "title".
310 <target dupnames="title" ids="id2">
315 Duplicate explicit/directive targets.
321 .. rubric:: this is a title too
326 <document source="test data">
328 Duplicate explicit/directive targets.
329 <target dupnames="title" ids="title">
332 <rubric dupnames="title" ids="id1">
334 <system_message backrefs="id1" level="2" line="9" source="test data" type="WARNING">
336 Duplicate explicit target name: "title".
344 Implicit section header target.
346 .. [TARGET] Citation target.
348 .. [#target] Autonumber-labeled footnote target.
352 Explicit internal target.
354 .. _target: Explicit_external_target
356 .. rubric:: directive with target
360 <document source="test data">
363 <section dupnames="target" ids="target">
367 Implicit section header target.
368 <citation dupnames="target" ids="id1">
371 <system_message backrefs="id1" level="1" line="8" source="test data" type="INFO">
373 Duplicate implicit target name: "target".
376 <footnote auto="1" dupnames="target" ids="id2">
377 <system_message backrefs="id2" level="2" line="10" source="test data" type="WARNING">
379 Duplicate explicit target name: "target".
381 Autonumber-labeled footnote target.
382 <system_message backrefs="id3" level="2" line="12" source="test data" type="WARNING">
384 Duplicate explicit target name: "target".
385 <target dupnames="target" ids="id3">
387 Explicit internal target.
388 <system_message backrefs="id4" level="2" line="16" source="test data" type="WARNING">
390 Duplicate explicit target name: "target".
391 <target dupnames="target" ids="id4" refuri="Explicit_external_target">
392 <rubric dupnames="target" ids="id5">
393 directive with target
394 <system_message backrefs="id5" level="2" line="4" source="test data" type="WARNING">
396 Duplicate explicit target name: "target".
399 .. _unescaped colon at end:: no good
401 .. _:: no good either
403 .. _escaped colon\:: OK
405 .. _`unescaped colon, quoted:`: OK
408 <document source="test data">
409 <comment xml:space="preserve">
410 _unescaped colon at end:: no good
411 <system_message level="2" line="1" source="test data" type="WARNING">
413 malformed hyperlink target.
414 <comment xml:space="preserve">
416 <system_message level="2" line="3" source="test data" type="WARNING">
418 malformed hyperlink target.
419 <target ids="escaped-colon" names="escaped\ colon:" refuri="OK">
420 <target ids="unescaped-colon-quoted" names="unescaped\ colon,\ quoted:" refuri="OK">
424 totest
['anonymous_targets'] = [
426 Anonymous external hyperlink target:
428 .. __: http://w3c.org/
431 <document source="test data">
433 Anonymous external hyperlink target:
434 <target anonymous="1" ids="id1" refuri="http://w3c.org/">
437 Anonymous external hyperlink target:
442 <document source="test data">
444 Anonymous external hyperlink target:
445 <target anonymous="1" ids="id1" refuri="http://w3c.org/">
448 Anonymous indirect hyperlink target:
453 <document source="test data">
455 Anonymous indirect hyperlink target:
456 <target anonymous="1" ids="id1" refname="reference">
459 Anonymous external hyperlink target, not indirect:
463 __ this URI ends with an underscore_
466 <document source="test data">
468 Anonymous external hyperlink target, not indirect:
469 <target anonymous="1" ids="id1" refuri="uri_">
470 <target anonymous="1" ids="id2" refuri="thisURIendswithanunderscore_">
473 Anonymous indirect hyperlink targets:
480 <document source="test data">
482 Anonymous indirect hyperlink targets:
483 <target anonymous="1" ids="id1" refname="reference">
484 <target anonymous="1" ids="id2" refname="a very long reference">
487 Mixed anonymous & named indirect hyperlink targets:
492 .. _target1: reference_
495 .. _target2: reference_
502 <document source="test data">
504 Mixed anonymous & named indirect hyperlink targets:
505 <target anonymous="1" ids="id1" refname="reference">
506 <target anonymous="1" ids="id2" refname="reference">
507 <target anonymous="1" ids="id3" refname="reference">
508 <target ids="target1" names="target1" refname="reference">
509 <system_message level="2" line="7" source="test data" type="WARNING">
511 Explicit markup ends without a blank line; unexpected unindent.
514 <target ids="target2" names="target2" refname="reference">
515 <target anonymous="1" ids="id4" refname="reference">
516 <target anonymous="1" ids="id5" refname="reference">
517 <target anonymous="1" ids="id6" refname="reference">
518 <system_message level="2" line="13" source="test data" type="WARNING">
520 Explicit markup ends without a blank line; unexpected unindent.
528 <document source="test data">
529 <comment xml:space="preserve">
535 if __name__
== '__main__':
537 unittest
.main(defaultTest
='suite')