Varia's website
https://varia.zone
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
5 days ago
|
# $Id: pep.py 7320 2012-01-19 22:33:02Z milde $
|
||
|
# Author: David Goodger <goodger@python.org>
|
||
|
# Copyright: This module has been placed in the public domain.
|
||
|
|
||
|
"""
|
||
|
Python Enhancement Proposal (PEP) Reader.
|
||
|
"""
|
||
|
|
||
|
__docformat__ = 'reStructuredText'
|
||
|
|
||
|
|
||
|
from docutils.readers import standalone
|
||
|
from docutils.transforms import peps, references, misc, frontmatter
|
||
|
from docutils.parsers import rst
|
||
|
|
||
|
|
||
|
class Reader(standalone.Reader):
|
||
|
|
||
|
supported = ('pep',)
|
||
|
"""Contexts this reader supports."""
|
||
|
|
||
|
settings_spec = (
|
||
|
'PEP Reader Option Defaults',
|
||
|
'The --pep-references and --rfc-references options (for the '
|
||
|
'reStructuredText parser) are on by default.',
|
||
|
())
|
||
|
|
||
|
config_section = 'pep reader'
|
||
|
config_section_dependencies = ('readers', 'standalone reader')
|
||
|
|
||
|
def get_transforms(self):
|
||
|
transforms = standalone.Reader.get_transforms(self)
|
||
|
# We have PEP-specific frontmatter handling.
|
||
|
transforms.remove(frontmatter.DocTitle)
|
||
|
transforms.remove(frontmatter.SectionSubTitle)
|
||
|
transforms.remove(frontmatter.DocInfo)
|
||
|
transforms.extend([peps.Headers, peps.Contents, peps.TargetNotes])
|
||
|
return transforms
|
||
|
|
||
|
settings_default_overrides = {'pep_references': 1, 'rfc_references': 1}
|
||
|
|
||
|
inliner_class = rst.states.Inliner
|
||
|
|
||
|
def __init__(self, parser=None, parser_name=None):
|
||
|
"""`parser` should be ``None``."""
|
||
|
if parser is None:
|
||
|
parser = rst.Parser(rfc2822=True, inliner=self.inliner_class())
|
||
|
standalone.Reader.__init__(self, parser, '')
|