当前位置: 首页>>代码示例>>Python>>正文


Python Publisher.process_programmatic_settings方法代码示例

本文整理汇总了Python中docutils.core.Publisher.process_programmatic_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Publisher.process_programmatic_settings方法的具体用法?Python Publisher.process_programmatic_settings怎么用?Python Publisher.process_programmatic_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils.core.Publisher的用法示例。

在下文中一共展示了Publisher.process_programmatic_settings方法的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: read_doc

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def read_doc(app, env, filename):
    # type: (Sphinx, BuildEnvironment, unicode) -> nodes.document
    """Parse a document and convert to doctree."""
    filetype = get_filetype(app.config.source_suffix, filename)
    input_class = app.registry.get_source_input(filetype)
    reader = SphinxStandaloneReader(app)
    source = input_class(app, env, source=None, source_path=filename,
                         encoding=env.config.source_encoding)
    parser = app.registry.create_source_parser(app, filetype)
    if parser.__class__.__name__ == 'CommonMarkParser' and parser.settings_spec == ():
        # a workaround for recommonmark
        #   If recommonmark.AutoStrictify is enabled, the parser invokes reST parser
        #   internally.  But recommonmark-0.4.0 does not provide settings_spec for reST
        #   parser.  As a workaround, this copies settings_spec for RSTParser to the
        #   CommonMarkParser.
        parser.settings_spec = RSTParser.settings_spec

    pub = Publisher(reader=reader,
                    parser=parser,
                    writer=SphinxDummyWriter(),
                    source_class=SphinxDummySourceClass,
                    destination=NullOutput())
    pub.set_components(None, 'restructuredtext', None)
    pub.process_programmatic_settings(None, env.settings, None)
    pub.set_source(source, filename)
    pub.publish()
    return pub.document
开发者ID:mgeier,项目名称:sphinx,代码行数:29,代码来源:io.py


示例2: get_sphinx

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def get_sphinx():
    sphinx = getattr(local_data, 'sphinx', None)
    if sphinx is None:
        sphinx = Sphinx(tempdir, tempdir, tempdir,
                        tempdir, 'json', status=None, warning=None)
        sphinx.builder.translator_class = CustomHTMLTranslator

        sphinx.env.patch_lookup_functions()
        sphinx.env.temp_data['docname'] = 'text'
        sphinx.env.temp_data['default_domain'] = 'py'

        pub = Publisher(reader=None,
                        parser=None,
                        writer=HTMLWriter(sphinx.builder),
                        source_class=io.StringInput,
                        destination_class=io.NullOutput)
        pub.set_components('standalone', 'restructuredtext', None)
        pub.process_programmatic_settings(None, sphinx.env.settings, None)
        pub.set_destination(None, None)

        sphinx.publisher = pub

        local_data.sphinx = sphinx

    return sphinx, sphinx.publisher
开发者ID:runyaga,项目名称:ptah,代码行数:27,代码来源:rst.py


示例3: parse_docstring

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def parse_docstring(doc):
    p = Publisher(source=doc, source_class=io.StringInput)
    p.set_reader('standalone', p.parser, 'restructuredtext')
    p.writer = Writer()
    p.process_programmatic_settings(None, None, None)
    p.set_source(doc, None)
    return p.publish()
开发者ID:waipeng,项目名称:hivemind,代码行数:9,代码来源:common.py


示例4: render

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
    def render(self):
        key = 'cia.apps.blog.%d' % self.id
        parts = cache.get(key)
        if not parts:

            # Convert the reST markup to a document tree
            document = publish_doctree(source = self.content)

            visitor = ImageTranslator(document)
            document.walkabout(visitor)

            #
            # Publish that document tree as HTML.  We can't use any of
            # the simpler methods in docutils.core, since we need
            # access to writer.parts
            #
            reader = doctree.Reader(parser_name='null')
            pub = Publisher(reader, None, None,
                            source = DocTreeInput(document),
                            destination_class = StringOutput)
            pub.set_writer('html4css1')
            pub.process_programmatic_settings(None, {
                'cloak_email_addresses': True,
                'initial_header_level': 2,
                }, None)

            pub.publish()
            parts = pub.writer.parts

            cache.set(key, parts)
        return parts
开发者ID:Justasic,项目名称:cia-vc,代码行数:33,代码来源:models.py


示例5: pypi_render

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def pypi_render(source):
    """
    Copied (and slightly adapted) from pypi.description_tools
    """
    ALLOWED_SCHEMES = '''file ftp gopher hdl http https imap mailto mms news
        nntp prospero rsync rtsp rtspu sftp shttp sip sips snews svn svn+ssh
        telnet wais irc'''.split()

    settings_overrides = {
        "raw_enabled": 0,  # no raw HTML code
        "file_insertion_enabled": 0,  # no file/URL access
        "halt_level": 2,  # at warnings or errors, raise an exception
        "report_level": 5,  # never report problems with the reST code
    }

    # capture publishing errors, they go to stderr
    old_stderr = sys.stderr
    sys.stderr = s = StringIO.StringIO()
    parts = None

    try:
        # Convert reStructuredText to HTML using Docutils.
        document = publish_doctree(source=source,
            settings_overrides=settings_overrides)

        for node in document.traverse():
            if node.tagname == '#text':
                continue
            if node.hasattr('refuri'):
                uri = node['refuri']
            elif node.hasattr('uri'):
                uri = node['uri']
            else:
                continue
            o = urlparse.urlparse(uri)
            if o.scheme not in ALLOWED_SCHEMES:
                raise TransformError('link scheme not allowed')

        # now turn the transformed document into HTML
        reader = readers.doctree.Reader(parser_name='null')
        pub = Publisher(reader, source=io.DocTreeInput(document),
            destination_class=io.StringOutput)
        pub.set_writer('html')
        pub.process_programmatic_settings(None, settings_overrides, None)
        pub.set_destination(None, None)
        pub.publish()
        parts = pub.writer.parts

    except:
        pass

    sys.stderr = old_stderr

    # original text if publishing errors occur
    if parts is None or len(s.getvalue()) > 0:
        return None
    else:
        return parts['body']
开发者ID:dstufft,项目名称:recliner,代码行数:60,代码来源:check_render.py


示例6: process_description

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def process_description(source, output_encoding='unicode'):
    """Given an source string, returns an HTML fragment as a string.

    The return value is the contents of the <body> tag.

    Parameters:

    - `source`: A multi-line text string; required.
    - `output_encoding`: The desired encoding of the output.  If a Unicode
      string is desired, use the default value of "unicode" .
    """
    # Dedent all lines of `source`.
    source = trim_docstring(source)

    settings_overrides = {
        'raw_enabled': 0,  # no raw HTML code
        'file_insertion_enabled': 0,  # no file/URL access
        'halt_level': 2,  # at warnings or errors, raise an exception
        'report_level': 5,  # never report problems with the reST code
        }

    parts = None

    # Convert reStructuredText to HTML using Docutils.
    document = publish_doctree(source=source,
        settings_overrides=settings_overrides)

    for node in document.traverse():
        if node.tagname == '#text':
            continue
        if node.hasattr('refuri'):
            uri = node['refuri']
        elif node.hasattr('uri'):
            uri = node['uri']
        else:
            continue
        o = urlparse(uri)
        if o.scheme not in ALLOWED_SCHEMES:
            raise TransformError('link scheme not allowed: {0}'.format(uri))

    # now turn the transformed document into HTML
    reader = readers.doctree.Reader(parser_name='null')
    pub = Publisher(reader, source=io.DocTreeInput(document),
        destination_class=io.StringOutput)
    pub.set_writer('html')
    pub.process_programmatic_settings(None, settings_overrides, None)
    pub.set_destination(None, None)
    pub.publish()
    parts = pub.writer.parts

    output = parts['body']

    if output_encoding != 'unicode':
        output = output.encode(output_encoding)

    return output
开发者ID:jfinkels,项目名称:sphinxcontrib-issuetracker,代码行数:58,代码来源:pypi.py


示例7: __init__

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
    def __init__(self):
        # publisher is used for html generation
        pub = Publisher(None, None, None, settings=None,
                             source_class=StringInput,
                             destination_class=StringOutput)
        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.process_programmatic_settings(None, None, None)
        pub.set_destination(None, None)

        self.pub = pub
开发者ID:petrushev,项目名称:qtrst,代码行数:12,代码来源:app.py


示例8: inspect

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def inspect(filename, source_path=None):
    "returns the document object before any transforms)"
    from docutils.core import Publisher

    pub = Publisher(source_class=io.FileInput)
    pub.set_reader("standalone", None, "restructuredtext")
    pub.process_programmatic_settings(None, None, None)
    pub.set_source(source_path=source_path)
    pub.set_io()
    return pub.reader.read(pub.source, pub.parser, pub.settings)
开发者ID:BackupTheBerlios,项目名称:lino-svn,代码行数:12,代码来源:restify.py


示例9: convert

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def convert(infilename, outfilename):
    print "converting %s to %s" % (infilename, outfilename)
    pub = Publisher()
    pub.set_components('standalone',        # reader
                       'restructuredtext',  # parser
                       'latex')             # writer (arg, will be discarded)
    pub.reader = StandaloneReader()
    pub.writer = VerseLaTeXWriter()
    pub.process_programmatic_settings(None, None, None)
    pub.set_source(source_path=infilename)
    pub.set_destination(destination_path=outfilename)
    pub.publish()
开发者ID:igemsoftware,项目名称:Michigan15,代码行数:14,代码来源:rst2verse.py


示例10: get_html

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
    def get_html(self, body_only=True, content_only=False, noclasses=False):
        import sys
        import pygments_rest
        from docutils.core import Publisher
        from docutils.io import StringInput, StringOutput
        from cStringIO import StringIO
        
        settings = {'doctitle_xform'     : 1,
                    'pep_references'     : 1,
                    'rfc_references'     : 1,
                    'footnote_references': 'superscript',
                    'output_encoding'    : 'unicode',
                    'report_level'       : 2, # 2=show warnings, 3=show only errors, 5=off (docutils.utils
                    }

        if content_only:
            post_rst = self.get_rst(noclasses=noclasses)
        else:
            post_rst = render_to('post_single.rst', 
                                 post=self, 
                                 noclasses=noclasses)
                             
        pub = Publisher(reader=None, 
                        parser=None, 
                        writer=None, 
                        settings=None,
                        source_class=StringInput,
                        destination_class=StringOutput)

        pub.set_components(reader_name='standalone',
                           parser_name='restructuredtext',
                           writer_name='html')
        pub.process_programmatic_settings(settings_spec=None,
                                          settings_overrides=settings,
                                          config_section=None)
        pub.set_source(post_rst,source_path=self.module_path)
        pub.set_destination(None, None)

        errors_io = StringIO()
        real_stderr = sys.stderr
        sys.stderr = errors_io
        try:
            html_full = pub.publish(enable_exit_status=False)
            html_body = ''.join(pub.writer.html_body)
        finally:
            sys.stderr = real_stderr
        errors = errors_io.getvalue()
        self._process_rest_errors(errors)

        errors_io.close()

        return html_body if body_only else html_full
开发者ID:mahmoud,项目名称:PythonDoesBlog,代码行数:54,代码来源:post.py


示例11: render_readme_like_pypi

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def render_readme_like_pypi(source, output_encoding='unicode'):
    """
    Render a ReST document just like PyPI does.
    """
    # Dedent all lines of `source`.
    source = trim_docstring(source)

    settings_overrides = {
        'raw_enabled': 0,  # no raw HTML code
        'file_insertion_enabled': 0,  # no file/URL access
        'halt_level': 2,  # at warnings or errors, raise an exception
        'report_level': 5,  # never report problems with the reST code
        }

    parts = None

    # Convert reStructuredText to HTML using Docutils.
    document = publish_doctree(source=source,
        settings_overrides=settings_overrides)

    for node in document.traverse():
        if node.tagname == '#text':
            continue
        if node.hasattr('refuri'):
            uri = node['refuri']
        elif node.hasattr('uri'):
            uri = node['uri']
        else:
            continue
        o = urlparse(uri)
        if o.scheme not in ALLOWED_SCHEMES:
            raise TransformError('link scheme not allowed: {0}'.format(uri))

    # now turn the transformed document into HTML
    reader = readers.doctree.Reader(parser_name='null')
    pub = Publisher(reader, source=io.DocTreeInput(document),
        destination_class=io.StringOutput)
    pub.set_writer('html')
    pub.process_programmatic_settings(None, settings_overrides, None)
    pub.set_destination(None, None)
    pub.publish()
    parts = pub.writer.parts

    output = parts['body']

    if output_encoding != 'unicode':
        output = output.encode(output_encoding)

    return output
开发者ID:dwlehman,项目名称:pyudev,代码行数:51,代码来源:test_pypi.py


示例12: _get_publisher

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
    def _get_publisher(self, source_path):
        extra_params = {'initial_header_level': '2',
                        'syntax_highlight': 'short',
                        'input_encoding': 'utf-8'}
        user_params = self.settings.get('DOCUTILS_SETTINGS')
        if user_params:
            extra_params.update(user_params)

        pub = Publisher(destination_class=StringOutput)
        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.writer.translator_class = HTMLTranslator
        pub.process_programmatic_settings(None, extra_params, None)
        pub.set_source(source_path=source_path)
        pub.publish()
        return pub
开发者ID:howthebodyworks,项目名称:pelican-plugins,代码行数:17,代码来源:bootstrap.py


示例13: read_doc

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def read_doc(app, env, filename):
    # type: (Sphinx, BuildEnvironment, unicode) -> nodes.document
    """Parse a document and convert to doctree."""
    reader = SphinxStandaloneReader(app, parsers=app.registry.get_source_parsers())
    source = SphinxFileInput(app, env, source=None, source_path=filename,
                             encoding=env.config.source_encoding)

    pub = Publisher(reader=reader,
                    writer=SphinxDummyWriter(),
                    source_class=SphinxDummySourceClass,
                    destination=NullOutput())
    pub.set_components(None, 'restructuredtext', None)
    pub.process_programmatic_settings(None, env.settings, None)
    pub.set_source(source, filename)
    pub.publish()
    return pub.document
开发者ID:LFYG,项目名称:sphinx,代码行数:18,代码来源:io.py


示例14: render_map

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def render_map(builder, node):
    if node:
        doc = new_document(b('<partial node>'))
        doc.append(node)

        publisher = Publisher( source_class = DocTreeInput, destination_class=StringOutput)
        publisher.set_components('standalone', 'restructuredtext', 'pseudoxml')
        publisher.reader = DoctreeReader()
        publisher.writer = DitaMapWriter(builder)
        publisher.process_programmatic_settings(None, {'output_encoding': 'utf-8'}, None)
        publisher.set_source(doc, None)
        publisher.set_destination(None, None)
        publisher.publish()
        return publisher.writer.output
    output = XML_HEAD
    output += u"<map></map>"
    return output
开发者ID:Deadolus,项目名称:learning-guides,代码行数:19,代码来源:ditamapwriter.py


示例15: check_rst

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
 def check_rst(self, rst):
     pub = Publisher(reader=None, parser=None, writer=None, settings=None,
                     source_class=io.StringInput,
                     destination_class=io.StringOutput)
     pub.set_components(reader_name='standalone',
                        parser_name='restructuredtext',
                        writer_name='pseudoxml')
     pub.process_programmatic_settings(
         settings_spec=None,
         settings_overrides={'output_encoding': 'unicode'},
         config_section=None,
     )
     pub.set_source(rst, source_path=None)
     pub.set_destination(destination=None, destination_path=None)
     output = pub.publish(enable_exit_status=False)
     self.assertLess(pub.document.reporter.max_level, 0)
     return output, pub
开发者ID:miyakogi,项目名称:m2r,代码行数:19,代码来源:test_renderer.py


示例16: __init__

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
	class HTMLGenerator:
		'''Really simple HTMLGenerator starting from publish_parts.

		It reuses the docutils.core.Publisher class, which means it is *not*
		threadsafe.
		'''
		def __init__(self,
			settings_spec=None,
			settings_overrides=dict(report_level=5, halt_level=5),
			config_section='general'):
			self.pub = Publisher(reader=None, parser=None, writer=None,
				settings=None,
				source_class=io.StringInput,
				destination_class=io.StringOutput)
			self.pub.set_components(reader_name='standalone',
				parser_name='restructuredtext',
				writer_name='html')
			# hack: JEP-0071 does not allow HTML char entities, so we hack our way
			# out of it.
			# &mdash; == u"\u2014"
			# a setting to only emit charater entities in the writer would be nice
			# FIXME: several &nbsp; are emitted, and they are explicitly forbidden
			# in the JEP
			# &nbsp; ==  u"\u00a0"
			self.pub.writer.translator_class.attribution_formats['dash'] = (
				u'\u2014', '')
			self.pub.process_programmatic_settings(settings_spec,
				settings_overrides,
				config_section)


		def create_xhtml(self, text,
			destination=None,
			destination_path=None,
			enable_exit_status=None):
			''' Create xhtml for a fragment of IM dialog.
			We can use the source_name to store info about
			the message.'''
			self.pub.set_source(text, None)
			self.pub.set_destination(destination, destination_path)
			output = self.pub.publish(enable_exit_status=enable_exit_status)
			# kludge until we can get docutils to stop generating (rare) &nbsp;
			# entities
			return u'\u00a0'.join(self.pub.writer.parts['fragment'].strip().split(
				'&nbsp;'))
开发者ID:kevin-teddy,项目名称:gajim,代码行数:47,代码来源:rst_xhtml_generator.py


示例17: aoeuaoeuaoeu_docs

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def aoeuaoeuaoeu_docs(f):
    '''
    I couldn't figure out how to use the docutils docstring parser, so I wrote
    my own. Can somebody show me the right way to do this?
    '''
    raise NotImplementedError
    from docutils.core import Publisher
    from docutils.io import StringInput
    pub = Publisher(None, None, None, settings = settings,
                    source_class = StringInput,
                    destination_class = destination_class)
    pub.set_components('standalone', 'restructuredtext', 'pseudoxml')
    pub.process_programmatic_settings(
        settings_spec, settings_overrides, config_section)
    pub.set_source(f.__doc__, f.__name__)
    pub.set_destination(None, f.__name__)
    output = pub.publish(enable_exit_status = False)
    return output, pub
    return publish_parts(f.__doc__, source_class = StringInput, source_path = f.__name__)
开发者ID:pombredanne,项目名称:horetu,代码行数:21,代码来源:junk.py


示例18: read_doc

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def read_doc(app, env, filename):
    # type: (Sphinx, BuildEnvironment, str) -> nodes.document
    """Parse a document and convert to doctree."""
    # set up error_handler for the target document
    error_handler = UnicodeDecodeErrorHandler(env.docname)
    codecs.register_error('sphinx', error_handler)  # type: ignore

    reader = SphinxStandaloneReader(app)
    filetype = get_filetype(app.config.source_suffix, filename)
    parser = app.registry.create_source_parser(app, filetype)
    if parser.__class__.__name__ == 'CommonMarkParser' and parser.settings_spec == ():
        # a workaround for recommonmark
        #   If recommonmark.AutoStrictify is enabled, the parser invokes reST parser
        #   internally.  But recommonmark-0.4.0 does not provide settings_spec for reST
        #   parser.  As a workaround, this copies settings_spec for RSTParser to the
        #   CommonMarkParser.
        parser.settings_spec = RSTParser.settings_spec

    input_class = app.registry.get_source_input(filetype)
    if input_class:
        # Sphinx-1.8 style
        source = input_class(app, env, source=None, source_path=filename,  # type: ignore
                             encoding=env.config.source_encoding)
        pub = Publisher(reader=reader,  # type: ignore
                        parser=parser,
                        writer=SphinxDummyWriter(),
                        source_class=SphinxDummySourceClass,
                        destination=NullOutput())
        pub.process_programmatic_settings(None, env.settings, None)
        pub.set_source(source, filename)
    else:
        # Sphinx-2.0 style
        pub = Publisher(reader=reader,
                        parser=parser,
                        writer=SphinxDummyWriter(),
                        source_class=SphinxFileInput,
                        destination=NullOutput())
        pub.process_programmatic_settings(None, env.settings, None)
        pub.set_source(source_path=filename)

    pub.publish()
    return pub.document
开发者ID:lmregus,项目名称:Portfolio,代码行数:44,代码来源:io.py


示例19: parts_from_doctree

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def parts_from_doctree(document, destination_path=None,
                         writer=Writer(), writer_name='html4css2',
                         settings=None, settings_spec=None,
                         settings_overrides=None, config_section=None,
                         enable_exit_status=None):
    """
    A version of :func:`docutils.core.publish_from_doctree` that supplies
    the "parts" rather than a regular string representation.
    """
    reader = Reader(parser_name='null')
    pub = Publisher(reader, None, writer,
                    source=io.DocTreeInput(document),
                    destination_class=io.StringOutput, settings=settings)
    if not writer and writer_name:
        pub.set_writer(writer_name)
    pub.process_programmatic_settings(
        settings_spec, settings_overrides, config_section)
    pub.set_destination(None, destination_path)
    output = pub.publish()
    return pub.writer.parts
开发者ID:tdavis,项目名称:django-publish,代码行数:22,代码来源:utils.py


示例20: parts_from_doctree

# 需要导入模块: from docutils.core import Publisher [as 别名]
# 或者: from docutils.core.Publisher import process_programmatic_settings [as 别名]
def parts_from_doctree(document, destination_path=None,
        writer=None, writer_name='pseudoxml',
        settings=None, settings_spec=None,
        settings_overrides=None, config_section=None,
        enable_exit_status=None):
    """
    Set up & run a `Publisher` to render from an existing document
    tree data structure, for programmatic use with string I/O.  Return
    the encoded string output.

    Note that document.settings is overridden; if you want to use the settings
    of the original `document`, pass settings=document.settings.

    Also, new document.transformer and document.reporter objects are
    generated.

    For encoded string output, be sure to set the 'output_encoding' setting to
    the desired encoding.  Set it to 'unicode' for unencoded Unicode string
    output.  Here's one way::

        publish_from_doctree(
            ..., settings_overrides={'output_encoding': 'unicode'})

    Parameters: `document` is a `docutils.nodes.document` object, an existing
    document tree.

    Other parameters: see `publish_programmatically`.
    """
    reader = docutils.readers.doctree.Reader(parser_name='null')
    pub = Publisher(reader, None, writer,
            source=io.DocTreeInput(document),
            destination_class=io.StringOutput, settings=settings)
    if not writer and writer_name:
        pub.set_writer(writer_name)
    pub.process_programmatic_settings(
            settings_spec, settings_overrides, config_section)
    pub.set_destination(None, destination_path)
    pub.publish(enable_exit_status=enable_exit_status)

    return pub.writer.parts
开发者ID:phbender,项目名称:brewpub,代码行数:42,代码来源:rstutils.py



注:本文中的docutils.core.Publisher.process_programmatic_settings方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。