| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
""" |
| 6 |
Simple internal document tree Writer, writes indented pseudo-XML. |
| 7 |
""" |
| 8 |
|
| 9 |
from __future__ import annotations |
| 10 |
|
| 11 |
__docformat__ = 'reStructuredText' |
| 12 |
|
| 13 |
from docutils import writers, frontend |
| 14 |
|
| 15 |
|
| 16 |
class Writer(writers.Writer): |
| 17 |
|
| 18 |
supported = ('pseudoxml', 'pprint', 'pformat') |
| 19 |
"""Formats this writer supports.""" |
| 20 |
|
| 21 |
settings_spec = ( |
| 22 |
'"Docutils pseudo-XML" Writer Options', |
| 23 |
None, |
| 24 |
(('Pretty-print <#text> nodes.', |
| 25 |
['--detailed'], |
| 26 |
{'action': 'store_true', 'validator': frontend.validate_boolean}), |
| 27 |
) |
| 28 |
) |
| 29 |
|
| 30 |
config_section = 'pseudoxml writer' |
| 31 |
config_section_dependencies = ('writers',) |
| 32 |
|
| 33 |
output = None |
| 34 |
"""Final translated form of `document`.""" |
| 35 |
|
| 36 |
def translate(self) -> None: |
| 37 |
self.output = self.document.pformat() |
| 38 |
|
| 39 |
def supports(self, format) -> bool: |
| 40 |
"""This writer supports all format-specific elements.""" |
| 41 |
return True |