HomeDashboard/.venv/lib/python3.12/site-packages/docutils/readers/pep.py
2026-01-03 14:54:18 +01:00

56 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# $Id: pep.py 10136 2025-05-20 15:48:27Z milde $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
Python Enhancement Proposal (PEP) Reader.
"""
from __future__ import annotations
__docformat__ = 'reStructuredText'
from docutils.readers import standalone
from docutils.transforms import peps, 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 = super().get_transforms()
# 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': True,
'rfc_references': True}
inliner_class = rst.states.Inliner
def __init__(self, parser=None, parser_name=None) -> None:
"""`parser` should be ``None``, `parser_name` is ignored.
The default parser is "rst" with PEP-specific settings
(since Docutils 0.3). Since Docutils 0.22, `parser` is ignored,
if it is a `str` instance.
"""
if parser is None or isinstance(parser, str):
parser = rst.Parser(rfc2822=True, inliner=self.inliner_class())
super().__init__(parser)