2 # Author: Martin Blais <blais@furius.ca>
3 # Copyright: This module has been placed in the public domain.
5 """Reader for existing document trees."""
7 from docutils
import readers
, utils
, transforms
10 class Reader(readers
.ReReader
):
13 Adapt the Reader API for an existing document tree.
15 The existing document tree must be passed as the ``source`` parameter to
16 the `docutils.core.Publisher` initializer, wrapped in a
17 `docutils.io.DocTreeInput` object::
19 pub = docutils.core.Publisher(
20 ..., source=docutils.io.DocTreeInput(document), ...)
22 The original document settings are overridden; if you want to use the
23 settings of the original document, pass ``settings=document.settings`` to
24 the Publisher call above.
27 supported
= ('doctree',)
29 config_section
= 'doctree reader'
30 config_section_dependencies
= ('readers',)
34 No parsing to do; refurbish the document tree instead.
35 Overrides the inherited method.
37 self
.document
= self
.input
38 # Create fresh Transformer object, to be populated from Writer
40 self
.document
.transformer
= transforms
.Transformer(self
.document
)
41 # Replace existing settings object with new one.
42 self
.document
.settings
= self
.settings
43 # Create fresh Reporter object because it is dependent on
45 self
.document
.reporter
= utils
.new_reporter(
46 self
.document
.get('source', ''), self
.document
.settings
)