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