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


Python BuildEnvironment.doc2path方法代码示例

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


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

示例1: Sphinx

# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import doc2path [as 别名]

#.........这里部分代码省略.........
        self.builder.cleanup()

    # ---- logging handling ----------------------------------------------------

    def _log(self, message, wfile, nonl=False):
        try:
            wfile.write(message)
        except UnicodeEncodeError:
            encoding = getattr(wfile, "encoding", "ascii") or "ascii"
            wfile.write(message.encode(encoding, "replace"))
        if not nonl:
            wfile.write("\n")
        if hasattr(wfile, "flush"):
            wfile.flush()
        self.messagelog.append(message)

    def warn(self, message, location=None, prefix="WARNING: "):
        """Emit a warning.

        If *location* is given, it should either be a tuple of (docname, lineno)
        or a string describing the location of the warning as well as possible.

        *prefix* usually should not be changed.

        .. note::

           For warnings emitted during parsing, you should use
           :meth:`.BuildEnvironment.warn` since that will collect all
           warnings during parsing for later output.
        """
        if isinstance(location, tuple):
            docname, lineno = location
            if docname:
                location = "%s:%s" % (self.env.doc2path(docname), lineno or "")
            else:
                location = None
        warntext = location and "%s: %s%s\n" % (location, prefix, message) or "%s%s\n" % (prefix, message)
        if self.warningiserror:
            raise SphinxWarning(warntext)
        self._warncount += 1
        self._log(warntext, self._warning, True)

    def info(self, message="", nonl=False):
        """Emit an informational message.

        If *nonl* is true, don't emit a newline at the end (which implies that
        more info output will follow soon.)
        """
        self._log(message, self._status, nonl)

    def verbose(self, message, *args, **kwargs):
        """Emit a verbose informational message.

        The message will only be emitted for verbosity levels >= 1 (i.e. at
        least one ``-v`` option was given).

        The message can contain %-style interpolation placeholders, which is
        formatted with either the ``*args`` or ``**kwargs`` when output.
        """
        if self.verbosity < 1:
            return
        if args or kwargs:
            message = message % (args or kwargs)
        self._log(message, self._status)

    def debug(self, message, *args, **kwargs):
开发者ID:861008761,项目名称:standard_flask_web,代码行数:70,代码来源:application.py

示例2: Sphinx

# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import doc2path [as 别名]

#.........这里部分代码省略.........
            self.emit('build-finished', None)
        self.builder.cleanup()

    # ---- logging handling ----------------------------------------------------

    def _log(self, message, wfile, nonl=False):
        try:
            wfile.write(message)
        except UnicodeEncodeError:
            encoding = getattr(wfile, 'encoding', 'ascii') or 'ascii'
            wfile.write(message.encode(encoding, 'replace'))
        if not nonl:
            wfile.write('\n')
        if hasattr(wfile, 'flush'):
            wfile.flush()

    def warn(self, message, location=None, prefix='WARNING: '):
        """Emit a warning.

        If *location* is given, it should either be a tuple of (docname, lineno)
        or a string describing the location of the warning as well as possible.

        *prefix* usually should not be changed.

        .. note::

           For warnings emitted during parsing, you should use
           :meth:`.BuildEnvironment.warn` since that will collect all
           warnings during parsing for later output.
        """
        if isinstance(location, tuple):
            docname, lineno = location
            if docname:
                location = '%s:%s' % (self.env.doc2path(docname), lineno or '')
            else:
                location = None
        warntext = location and '%s: %s%s\n' % (location, prefix, message) or \
                   '%s%s\n' % (prefix, message)
        if self.warningiserror:
            raise SphinxWarning(warntext)
        self._warncount += 1
        self._log(warntext, self._warning, True)

    def info(self, message='', nonl=False):
        """Emit an informational message.

        If *nonl* is true, don't emit a newline at the end (which implies that
        more info output will follow soon.)
        """
        self._log(message, self._status, nonl)

    def verbose(self, message, *args, **kwargs):
        """Emit a verbose informational message.

        The message will only be emitted for verbosity levels >= 1 (i.e. at
        least one ``-v`` option was given).

        The message can contain %-style interpolation placeholders, which is
        formatted with either the ``*args`` or ``**kwargs`` when output.
        """
        if self.verbosity < 1:
            return
        if args or kwargs:
            message = message % (args or kwargs)
        self._log(message, self._status)
开发者ID:Scalr,项目名称:sphinx,代码行数:69,代码来源:application.py

示例3: Sphinx

# 需要导入模块: from sphinx.environment import BuildEnvironment [as 别名]
# 或者: from sphinx.environment.BuildEnvironment import doc2path [as 别名]

#.........这里部分代码省略.........
            # wfile.write accept only str, not bytes.So, we encode and replace
            # non-encodable characters, then decode them.
            wfile.write(message.encode(encoding, 'replace').decode(encoding))
        if not nonl:
            wfile.write('\n')
        if hasattr(wfile, 'flush'):
            wfile.flush()
        self.messagelog.append(message)

    def warn(self, message, location=None, prefix='WARNING: ',
             type=None, subtype=None, colorfunc=darkred):
        # type: (unicode, unicode, unicode, unicode, unicode, Callable) -> None
        """Emit a warning.

        If *location* is given, it should either be a tuple of (docname, lineno)
        or a string describing the location of the warning as well as possible.

        *prefix* usually should not be changed.

        *type* and *subtype* are used to suppress warnings with :confval:`suppress_warnings`.

        .. note::

           For warnings emitted during parsing, you should use
           :meth:`.BuildEnvironment.warn` since that will collect all
           warnings during parsing for later output.
        """
        if is_suppressed_warning(type, subtype, self.config.suppress_warnings):
            return

        if isinstance(location, tuple):
            docname, lineno = location
            if docname:
                location = '%s:%s' % (self.env.doc2path(docname), lineno or '')
            else:
                location = None
        warntext = location and '%s: %s%s\n' % (location, prefix, message) or \
            '%s%s\n' % (prefix, message)
        if self.warningiserror:
            raise SphinxWarning(warntext)
        self._warncount += 1
        self._log(colorfunc(warntext), self._warning, True)

    def info(self, message='', nonl=False):
        # type: (unicode, bool) -> None
        """Emit an informational message.

        If *nonl* is true, don't emit a newline at the end (which implies that
        more info output will follow soon.)
        """
        self._log(message, self._status, nonl)

    def verbose(self, message, *args, **kwargs):
        # type: (unicode, Any, Any) -> None
        """Emit a verbose informational message.

        The message will only be emitted for verbosity levels >= 1 (i.e. at
        least one ``-v`` option was given).

        The message can contain %-style interpolation placeholders, which is
        formatted with either the ``*args`` or ``**kwargs`` when output.
        """
        if self.verbosity < 1:
            return
        if args or kwargs:
            message = message % (args or kwargs)
开发者ID:Felix-neko,项目名称:sphinx,代码行数:70,代码来源:application.py


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