Add note to run alltest.py on svn version after the release.
[docutils.git] / docutils / readers / doctree.py
blob929b0f35463a93966c3c54c1613d0bdb48c2de5a
1 # $Id$
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):
12 """
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.
25 """
27 supported = ('doctree',)
29 config_section = 'doctree reader'
30 config_section_dependencies = ('readers',)
32 def parse(self):
33 """
34 No parsing to do; refurbish the document tree instead.
35 Overrides the inherited method.
36 """
37 self.document = self.input
38 # Create fresh Transformer object, to be populated from Writer
39 # component.
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
44 # (new) settings.
45 self.document.reporter = utils.new_reporter(
46 self.document.get('source', ''), self.document.settings)