2 # Contact: blais@furius.ca
5 # Copyright: This module has been placed in the public domain.
7 """Reader for existing document trees."""
9 from docutils
import readers
, utils
12 class Reader(readers
.Reader
):
15 Adapt the Reader API for an existing document tree.
17 The existing document tree must be passed as the ``source`` parameter to
18 the `docutils.core.Publisher` initializer, wrapped in a
19 `docutils.io.DoctreeInput` object::
21 pub = docutils.core.Publisher(
22 ..., source=docutils.io.DoctreeInput(document), ...)
24 The original document settings are overridden; if you want to use the
25 settings of the original document, pass ``settings=document.settings`` to
26 the Publisher call above.
29 supported
= ('doctree',)
31 config_section
= 'doctree reader'
32 config_section_dependencies
= ('readers',)
36 No parsing to do; refurbish the document tree instead.
37 Overrides the inherited method.
39 self
.document
= self
.input
40 # Restore the reporter after document serialization:
41 if self
.document
.reporter
is None:
42 self
.document
.reporter
= utils
.new_reporter(
43 self
.source
.source_path
, self
.settings
)
44 # Override document settings with new settings:
45 self
.document
.settings
= self
.settings