comparison env/lib/python3.9/site-packages/docutils/readers/doctree.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # $Id: doctree.py 4564 2006-05-21 20:44:42Z wiemann $
2 # Author: Martin Blais <blais@furius.ca>
3 # Copyright: This module has been placed in the public domain.
4
5 """Reader for existing document trees."""
6
7 from docutils import readers, utils, transforms
8
9
10 class Reader(readers.ReReader):
11
12 """
13 Adapt the Reader API for an existing document tree.
14
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::
18
19 pub = docutils.core.Publisher(
20 ..., source=docutils.io.DocTreeInput(document), ...)
21
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 """
26
27 supported = ('doctree',)
28
29 config_section = 'doctree reader'
30 config_section_dependencies = ('readers',)
31
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)