docutils.readers package

This package contains Docutils Reader modules.

class Reader(parser=None, parser_name=None)[source]

Bases: Component

Abstract base class for docutils Readers.

Each reader module or package must export a subclass also called ‘Reader’.

The two steps of a Reader’s responsibility are to read data from the source Input object and parse the data with the Parser object. Call read() to process a document.

component_type = 'reader'

Name of the component type (‘reader’, ‘parser’, ‘writer’). Override in subclasses.

config_section = 'readers'

The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.

get_transforms()[source]

Transforms required by this class. Override in subclasses.

__init__(parser=None, parser_name=None)[source]

Initialize the Reader instance.

Several instance attributes are defined with dummy initial values. Subclasses may use these attributes as they wish.

parser

A parsers.Parser instance shared by all doctrees. May be left unspecified if the document source determines the parser.

source

docutils.io IO object, source of input data.

input

Raw text input; either a single string or, for more complex cases, a collection of strings.

set_parser(parser_name)[source]

Set self.parser by name.

read(source, parser, settings)[source]
parse()[source]

Parse self.input into a document tree.

new_document()[source]

Create and return a new empty document tree (root node).

class ReReader(parser=None, parser_name=None)[source]

Bases: Reader

A reader which rereads an existing document tree (e.g. a deserializer).

Often used in conjunction with writers.UnfilteredWriter.

get_transforms()[source]

Transforms required by this class. Override in subclasses.

get_reader_class(reader_name)[source]

Return the Reader class from the reader_name module.

Submodules