docutils.transforms.peps module

Transforms for PEP processing.

  • Headers: Used to transform a PEP’s initial RFC-2822 header. It remains a field list, but some entries get processed.

  • Contents: Auto-inserts a table of contents.

  • PEPZero: Special processing for PEP 0.

class Headers(document, startnode=None)[source]

Bases: Transform

Process fields in a PEP’s initial RFC-2822 header.

default_priority = 360

Numerical priority of this transform, 0 through 999 (override).

pep_url = 'pep-%04d'
pep_cvs_url = 'http://hg.python.org/peps/file/default/pep-%04d.txt'
rcs_keyword_substitutions = ((re.compile('\\$RCSfile: (.+),v \\$$', re.IGNORECASE), '\\1'), (re.compile('\\$[a-zA-Z]+: (.+) \\$$'), '\\1'))
apply()[source]

Override to apply the transform to the document tree.

class Contents(document, startnode=None)[source]

Bases: Transform

Insert an empty table of contents topic and a transform placeholder into the document after the RFC 2822 header.

default_priority = 380

Numerical priority of this transform, 0 through 999 (override).

apply()[source]

Override to apply the transform to the document tree.

class TargetNotes(document, startnode=None)[source]

Bases: Transform

Locate the “References” section, insert a placeholder for an external target footnote insertion transform at the end, and schedule the transform to run immediately.

default_priority = 520

Numerical priority of this transform, 0 through 999 (override).

apply()[source]

Override to apply the transform to the document tree.

cleanup_callback(pending)[source]

Remove an empty “References” section.

Called after the references.TargetNotes transform is complete.

class PEPZero(document, startnode=None)[source]

Bases: Transform

Special processing for PEP 0.

default_priority = 760

Numerical priority of this transform, 0 through 999 (override).

apply()[source]

Override to apply the transform to the document tree.

class PEPZeroSpecial(document)[source]

Bases: SparseNodeVisitor

Perform the special processing needed by PEP 0:

  • Mask email addresses.

  • Link PEP numbers in the second column of 4-column tables to the PEPs themselves.

pep_url = 'pep-%04d'
unknown_visit(node)[source]

Called when entering unknown Node types.

Raise an exception unless overridden.

visit_reference(node)[source]
visit_field_list(node)[source]
visit_tgroup(node)[source]
visit_colspec(node)[source]
visit_row(node)[source]
visit_entry(node)[source]
mask_email(ref, pepno=None)[source]

Mask the email address in ref and return a replacement node.

ref is returned unchanged if it contains no email address.

For email addresses such as “user@host”, mask the address as “user at host” (text) to thwart simple email address harvesters (except for those listed in non_masked_addresses). If a PEP number (pepno) is given, return a reference including a default email subject.