Ejemplo n.º 1
0
def cli_du_publisher(reader_name='mpe', parser=None, parser_name='rst',
        writer=None, writer_name='pseudoxml', description=''):

    """
    Simple wrapper for ``docutils.core.publish_cmdline``.
    During development, this should still be working.

    Shortcomings are it cannot load settings-specs from transforms,
    or perform processing only (without rendering).
    It does not handle stores for transforms directly as Nabu does.
    But, given that transforms could handle storage
    initialization themselves, and that the Reader/Parser/Writer 'parent'
    component can hold the settings-specs, should make it fairly easy to port
    Builder code back to work with docutils.
    """

    # XXX: how far does inline customization go? parser = Parser(inliner=Inliner())
    reader_class = comp.get_reader_class(reader_name)
    parser_class = None
    if not parser:
        parser_class = comp.get_parser_class(parser_name)
        parser = parser_class()
    if not writer:
        writer_class = comp.get_writer_class(writer_name)
        writer = writer_class()

    publish_cmdline(
            parser=parser,
            parser_name=parser_name,
            reader=reader_class(parser),
            reader_name=reader_name,
            writer=writer,
            writer_name=writer_name,
            description=description)
Ejemplo n.º 2
0
 def test_2_get_reader_class(self):
     for Reader, names in DuComponentLoaderMonkeyPatchTest.reader:
         for name in names:
         	self.assert_( issubclass(Reader, docutils.readers.Reader),
         	        Reader )
             self.assertEquals( Reader, comp.get_reader_class(name) )
Ejemplo n.º 3
0
#!/usr/bin/python
"""
A minimal front end to the Docutils Publisher, producing Docutils XML.
This uses the (experimental?) Python source reader. 
TODO: there is no HTML writer compatible with it afaik

Copyleft 2009  Berend van Berkum <*****@*****.**>
This file has been placed in the Public Domain.
"""

import sys, os
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__),
    '..', 'lib')))
import dotmpe.du.ext
from dotmpe.du import comp
from dotmpe.du.ext.reader import mpe

try:
    import locale
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

from docutils.core import publish_cmdline, default_description

publish_cmdline(
        reader=comp.get_reader_class('python')(), 
        writer=comp.get_writer_class('dotmpe-html')())