當前位置: 首頁>>代碼示例>>Python>>正文


Python docutils.core方法代碼示例

本文整理匯總了Python中docutils.core方法的典型用法代碼示例。如果您正苦於以下問題:Python docutils.core方法的具體用法?Python docutils.core怎麽用?Python docutils.core使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在docutils的用法示例。


在下文中一共展示了docutils.core方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: convert_doc

# 需要導入模塊: import docutils [as 別名]
# 或者: from docutils import core [as 別名]
def convert_doc(rst_string, view_file_url=None):
    """ Utility to load an RST file and turn it into fancy HTML. """
    rst = modify_rst(rst_string, view_file_url)

    overrides = {"report_level": "quiet"}
    try:
        html = docutils.core.publish_parts(
            source=rst, writer_name="html", settings_overrides=overrides
        )
    except Exception:
        return "<pre>%s</pre>" % jinja2.escape(rst)

    else:

        html_string = html["html_body"]

        html_string = modify_html(html_string)

        html_string = markupsafe.Markup(html_string)
        return html_string 
開發者ID:Pagure,項目名稱:pagure,代碼行數:22,代碼來源:doc_utils.py

示例2: format_doc

# 需要導入模塊: import docutils [as 別名]
# 或者: from docutils import core [as 別名]
def format_doc(docstring):
    '''Return parsed documentation string, stripping RST markup.
    '''

    if not docstring:
        return ''

    # pylint: disable=unused-variable
    output, pub = docutils.core.publish_programmatically(
        source_class=docutils.io.StringInput,
        source=' '.join(docstring.strip().split()),
        source_path=None,
        destination_class=docutils.io.NullOutput, destination=None,
        destination_path=None,
        reader=None, reader_name='standalone',
        parser=None, parser_name='restructuredtext',
        writer=None, writer_name='null',
        settings=None, settings_spec=None, settings_overrides=None,
        config_section=None, enable_exit_status=None)
    return pub.writer.document.astext() 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:22,代碼來源:utils.py

示例3: run

# 需要導入模塊: import docutils [as 別名]
# 或者: from docutils import core [as 別名]
def run(self):
        import os
        import pathlib
        from babel.messages.frontend import CommandLineInterface

        self.announce("Compiling ui translation files", level=distutils.log.INFO)
        ui_dir = pathlib.Path("parsec/core/gui")
        tr_dir = ui_dir / "tr"
        rc_dir = ui_dir / "rc" / "translations"
        os.makedirs(rc_dir, exist_ok=True)
        languages = ["fr", "en"]
        for lang in languages:
            args = [
                "_",
                "compile",
                "-i",
                str(tr_dir / f"parsec_{lang}.po"),
                "-o",
                str(rc_dir / f"parsec_{lang}.mo"),
            ]
            CommandLineInterface().run(args) 
開發者ID:Scille,項目名稱:parsec-cloud,代碼行數:23,代碼來源:setup.py

示例4: _get_publisher

# 需要導入模塊: import docutils [as 別名]
# 或者: from docutils import core [as 別名]
def _get_publisher(self, source, source_file_path):
        # This is a slightly modified copy of `RstReader._get_publisher`
        extra_params = {'initial_header_level': '4',
                        'syntax_highlight': 'short',
                        'input_encoding': 'utf-8',
                        'exit_status_level': 2,
                        'embed_stylesheet': False}
        user_params = self.settings.get('DOCUTILS_SETTINGS')
        if user_params:
            extra_params.update(user_params)

        pub = docutils.core.Publisher(
            source_class=docutils.io.StringInput,
            destination_class=docutils.io.StringOutput)
        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.writer.translator_class = PelicanHTMLTranslator
        pub.process_programmatic_settings(None, extra_params, None)
        pub.set_source(source=source, source_path=source_file_path)
        pub.publish(enable_exit_status=True)
        return pub

    # You need to have a read method, which takes a filename and returns
    # some content and the associated metadata. 
開發者ID:pyvideo,項目名稱:pyvideo,代碼行數:25,代碼來源:json_reader.py


注:本文中的docutils.core方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。