docutils.writers package
This package contains Docutils Writer modules.
- class Writer[source]
Bases:
Component
Abstract base class for docutils Writers.
Each writer module or package must export a subclass also called ‘Writer’. Each writer must support all standard node types listed in docutils.nodes.node_class_names.
The write() method is the main entry point.
- component_type = 'writer'
Name of the component type (‘reader’, ‘parser’, ‘writer’). Override in subclasses.
- config_section = 'writers'
The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.
- document = None
The document to write (Docutils doctree); set by write().
- output = None
Final translated form of document
(str for text, bytes for binary formats); set by translate().
- language = None
Language module for the document; set by write().
- destination = None
docutils.io Output object; where to write the document.
Set by write().
- parts
Mapping of document part names to fragments of self.output.
See Writer.assemble_parts() below and <https://docutils.sourceforge.io/docs/api/publisher.html>.
- write(document, destination)[source]
Process a document into its final form.
Translate document (a Docutils document tree) into the Writer’s native format, and write it out to its destination (a docutils.io.Output subclass object).
Normally not overridden or extended in subclasses.
- translate()[source]
Do final translation of self.document into self.output. Called from write. Override in subclasses.
Usually done with a docutils.nodes.NodeVisitor subclass, in combination with a call to docutils.nodes.Node.walk() or docutils.nodes.Node.walkabout(). The
NodeVisitor
subclass must support all standard elements (listed in docutils.nodes.node_class_names) and possibly non-standard elements used by the current Reader as well.
- assemble_parts()[source]
Assemble the self.parts dictionary. Extend in subclasses.
See <https://docutils.sourceforge.io/docs/api/publisher.html>.
- class UnfilteredWriter[source]
Bases:
Writer
A writer that passes the document tree on unchanged (e.g. a serializer.)
Documents written by UnfilteredWriters are typically reused at a later date using a subclass of readers.ReReader.