1 | # Author: David Goodger |
---|
2 | # Contact: goodger@users.sourceforge.net |
---|
3 | # Revision: $Revision: 3892 $ |
---|
4 | # Date: $Date: 2005-09-20 22:04:53 +0200 (Tue, 20 Sep 2005) $ |
---|
5 | # Copyright: This module has been placed in the public domain. |
---|
6 | |
---|
7 | """ |
---|
8 | Standalone file Reader for the reStructuredText markup syntax. |
---|
9 | """ |
---|
10 | |
---|
11 | __docformat__ = 'reStructuredText' |
---|
12 | |
---|
13 | |
---|
14 | import sys |
---|
15 | from docutils import frontend, readers |
---|
16 | from docutils.transforms import frontmatter, references, misc |
---|
17 | |
---|
18 | |
---|
19 | class Reader(readers.Reader): |
---|
20 | |
---|
21 | supported = ('standalone',) |
---|
22 | """Contexts this reader supports.""" |
---|
23 | |
---|
24 | document = None |
---|
25 | """A single document tree.""" |
---|
26 | |
---|
27 | settings_spec = ( |
---|
28 | 'Standalone Reader', |
---|
29 | None, |
---|
30 | (('Disable the promotion of a lone top-level section title to ' |
---|
31 | 'document title (and subsequent section title to document ' |
---|
32 | 'subtitle promotion; enabled by default).', |
---|
33 | ['--no-doc-title'], |
---|
34 | {'dest': 'doctitle_xform', 'action': 'store_false', 'default': 1, |
---|
35 | 'validator': frontend.validate_boolean}), |
---|
36 | ('Disable the bibliographic field list transform (enabled by ' |
---|
37 | 'default).', |
---|
38 | ['--no-doc-info'], |
---|
39 | {'dest': 'docinfo_xform', 'action': 'store_false', 'default': 1, |
---|
40 | 'validator': frontend.validate_boolean}), |
---|
41 | ('Activate the promotion of lone subsection titles to ' |
---|
42 | 'section subtitles (disabled by default).', |
---|
43 | ['--section-subtitles'], |
---|
44 | {'dest': 'sectsubtitle_xform', 'action': 'store_true', 'default': 0, |
---|
45 | 'validator': frontend.validate_boolean}), |
---|
46 | ('Deactivate the promotion of lone subsection titles.', |
---|
47 | ['--no-section-subtitles'], |
---|
48 | {'dest': 'sectsubtitle_xform', 'action': 'store_false', |
---|
49 | 'validator': frontend.validate_boolean}), |
---|
50 | )) |
---|
51 | |
---|
52 | config_section = 'standalone reader' |
---|
53 | config_section_dependencies = ('readers',) |
---|
54 | |
---|
55 | def get_transforms(self): |
---|
56 | return readers.Reader.get_transforms(self) + [ |
---|
57 | references.Substitutions, |
---|
58 | references.PropagateTargets, |
---|
59 | frontmatter.DocTitle, |
---|
60 | frontmatter.SectionSubTitle, |
---|
61 | frontmatter.DocInfo, |
---|
62 | references.AnonymousHyperlinks, |
---|
63 | references.IndirectHyperlinks, |
---|
64 | references.Footnotes, |
---|
65 | references.ExternalTargets, |
---|
66 | references.InternalTargets, |
---|
67 | references.DanglingReferences, |
---|
68 | misc.Transitions, |
---|
69 | ] |
---|