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


Python console.red方法代碼示例

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


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

示例1: write_doc

# 需要導入模塊: from sphinx.util import console [as 別名]
# 或者: from sphinx.util.console import red [as 別名]
def write_doc(self, docname, doctree):
        self.checker.push_filters(self.env.spelling_document_filters[docname])

        for node in doctree.traverse(docutils.nodes.Text):
            if node.tagname == '#text' and node.parent and node.parent.tagname in TEXT_NODES:

                # Figure out the line number for this node by climbing the
                # tree until we find a node that has a line number.
                lineno = None
                parent = node
                seen = set()
                while lineno is None:
                    #self.info('looking for line number on %r' % node)
                    seen.add(parent)
                    parent = node.parent
                    if parent is None or parent in seen:
                        break
                    lineno = parent.line
                filename = self.env.doc2path(docname, base=None)

                # Check the text of the node.
                for word, suggestions in self.checker.check(node.astext()):
                    msg_parts = []
                    if lineno:
                        msg_parts.append(darkgreen('(line %3d)' % lineno))
                    msg_parts.append(red(word))
                    msg_parts.append(self.format_suggestions(suggestions))
                    msg = ' '.join(msg_parts)
                    self.info(msg)
                    self.output.write(u"%s:%s: (%s) %s\n" % (
                            self.env.doc2path(docname, None),
                            lineno, word,
                            self.format_suggestions(suggestions),
                            ))

                    # We found at least one bad spelling, so set the status
                    # code for the app to a value that indicates an error.
                    self.app.statuscode = 1

        self.checker.pop_filters()
        return 
開發者ID:slipguru,項目名稱:palladio,代碼行數:43,代碼來源:spelling.py

示例2: process_meta

# 需要導入模塊: from sphinx.util import console [as 別名]
# 或者: from sphinx.util.console import red [as 別名]
def process_meta(app, doctree, fromdocname):
    env = app.builder.env
    env.page_to_version = defaultdict(set)
    env.version_to_page = defaultdict(set)

    # index metadata
    for pagename, metadata in iter(env.metadata.items()):
        if 'version' in metadata:
            version = metadata['version']
            env.page_to_version[pagename] = version
            env.version_to_page[version].add(pagename)

            if fromdocname == pagename:

                # Alert on outdated version
                current_version = env.config['version']
                if version != current_version:
                    text = 'This page documents version {old} and has not yet been updated for version {new}'.format(
                        old=version,
                        new=current_version,
                    )

                    if app.config['versionwarning_node']:
                        prose = nodes.paragraph(text, text)
                        warning = nodes.warning(prose, prose)
                        doctree.insert(0, warning)
                    if app.config['versionwarning_console']:
                        app.warn(bold('[Version Warning: %s] ' % pagename) + red(text)) 
開發者ID:Sitecore,項目名稱:Helix.Docs,代碼行數:30,代碼來源:versionwarning.py


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