| Tor Norbye | 3a2425a | 2013-11-04 10:16:08 -0800 | [diff] [blame^] | 1 | # $Id: pep.py 4564 2006-05-21 20:44:42Z wiemann $ |
| 2 | # Author: David Goodger <goodger@python.org> |
| 3 | # Copyright: This module has been placed in the public domain. |
| 4 | |
| 5 | """ |
| 6 | Python Enhancement Proposal (PEP) Reader. |
| 7 | """ |
| 8 | |
| 9 | __docformat__ = 'reStructuredText' |
| 10 | |
| 11 | |
| 12 | from docutils.readers import standalone |
| 13 | from docutils.transforms import peps, references, misc, frontmatter |
| 14 | from docutils.parsers import rst |
| 15 | |
| 16 | |
| 17 | class Reader(standalone.Reader): |
| 18 | |
| 19 | supported = ('pep',) |
| 20 | """Contexts this reader supports.""" |
| 21 | |
| 22 | settings_spec = ( |
| 23 | 'PEP Reader Option Defaults', |
| 24 | 'The --pep-references and --rfc-references options (for the ' |
| 25 | 'reStructuredText parser) are on by default.', |
| 26 | ()) |
| 27 | |
| 28 | config_section = 'pep reader' |
| 29 | config_section_dependencies = ('readers', 'standalone reader') |
| 30 | |
| 31 | def get_transforms(self): |
| 32 | transforms = standalone.Reader.get_transforms(self) |
| 33 | # We have PEP-specific frontmatter handling. |
| 34 | transforms.remove(frontmatter.DocTitle) |
| 35 | transforms.remove(frontmatter.SectionSubTitle) |
| 36 | transforms.remove(frontmatter.DocInfo) |
| 37 | transforms.extend([peps.Headers, peps.Contents, peps.TargetNotes]) |
| 38 | return transforms |
| 39 | |
| 40 | settings_default_overrides = {'pep_references': 1, 'rfc_references': 1} |
| 41 | |
| 42 | inliner_class = rst.states.Inliner |
| 43 | |
| 44 | def __init__(self, parser=None, parser_name=None): |
| 45 | """`parser` should be ``None``.""" |
| 46 | if parser is None: |
| 47 | parser = rst.Parser(rfc2822=1, inliner=self.inliner_class()) |
| 48 | standalone.Reader.__init__(self, parser, '') |