pseudoxml.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # $Id: pseudoxml.py 9043 2022-03-11 12:09:16Z milde $
  2. # Author: David Goodger <goodger@python.org>
  3. # Copyright: This module has been placed in the public domain.
  4. """
  5. Simple internal document tree Writer, writes indented pseudo-XML.
  6. """
  7. __docformat__ = 'reStructuredText'
  8. from docutils import writers, frontend
  9. class Writer(writers.Writer):
  10. supported = ('pseudoxml', 'pprint', 'pformat')
  11. """Formats this writer supports."""
  12. settings_spec = (
  13. '"Docutils pseudo-XML" Writer Options',
  14. None,
  15. (('Pretty-print <#text> nodes.',
  16. ['--detailed'],
  17. {'action': 'store_true', 'validator': frontend.validate_boolean}),
  18. )
  19. )
  20. config_section = 'pseudoxml writer'
  21. config_section_dependencies = ('writers',)
  22. output = None
  23. """Final translated form of `document`."""
  24. def translate(self):
  25. self.output = self.document.pformat()
  26. def supports(self, format):
  27. """This writer supports all format-specific elements."""
  28. return True