root / dotorg / trunk / docutils / docutils / readers / bep.py

Revision 10307, 1.5 kB (checked in by dave, 10 months ago)

docutils for creating BEPs.

These are heavily derived from David Goodger's scripts for generating
Python PEPs.

Line 
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"""
6Python Enhancement Proposal (BEP) Reader.
7"""
8
9__docformat__ = 'reStructuredText'
10
11
12from docutils.readers import standalone
13from docutils.transforms import beps, references, misc, frontmatter
14from docutils.parsers import rst
15
16
17class Reader(standalone.Reader):
18
19    supported = ('bep',)
20    """Contexts this reader supports."""
21
22    settings_spec = (
23        'BEP Reader Option Defaults',
24        'The --bep-references and --rfc-references options (for the '
25        'reStructuredText parser) are on by default.',
26        ())
27
28    config_section = 'bep reader'
29    config_section_dependencies = ('readers', 'standalone reader')
30
31    def get_transforms(self):
32        transforms = standalone.Reader.get_transforms(self)
33        # We have BEP-specific frontmatter handling.
34        transforms.remove(frontmatter.DocTitle)
35        transforms.remove(frontmatter.SectionSubTitle)
36        transforms.remove(frontmatter.DocInfo)
37        transforms.extend([beps.Headers, beps.Contents, beps.TargetNotes])
38        return transforms
39
40    settings_default_overrides = {'bep_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, '')
Note: See TracBrowser for help on using the browser.