Fixed bug introduced in doctree reader, added pickle test back in.
[docutils.git] / docutils / readers / doctree.py
blob5a4371983df2da8cdfc8d4dc05e45d329ea6a514
1 # Author: Martin Blais
2 # Contact: blais@furius.ca
3 # Revision: $Revision$
4 # Date: $Date$
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):
14 """
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.
27 """
29 supported = ('doctree',)
31 config_section = 'doctree reader'
32 config_section_dependencies = ('readers',)
34 def parse(self):
35 """
36 No parsing to do; refurbish the document tree instead.
37 Overrides the inherited method.
38 """
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