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


Python sphinx.errors方法代碼示例

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


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

示例1: check_undocumented_arguments

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def check_undocumented_arguments(self, ignored_options=None):
        """ Call this to check if any undocumented arguments are left.

            While the documentation talks about a
            'SparseNodeVisitor.depart_document()' function, this function does
            not exists. (For details see implementation of
            :py:meth:`NodeVisitor.dispatch_departure()`) So we need to
            manually call this.
        """
        if ignored_options is None:
            ignored_options = set()
        left_over_args = self.args - ignored_options
        if left_over_args:
            raise sphinx.errors.SphinxError(
                'Undocumented arguments for command {!r}: {!r}'.format(
                    self.command, ', '.join(sorted(left_over_args)))) 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:18,代碼來源:dochelpers.py

示例2: visit_section

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def visit_section(self, node):
        """ Checks if the visited sub-command section nodes exists and it
            options are in sync.

            Uses :py:class:`OptionsCheckVisitor` for checking
            sub-commands options
        """
        # pylint: disable=no-self-use
        title = str(node[0][0])
        if title.upper() == SUBCOMMANDS_TITLE:
            return

        sub_cmd = self.command + ' ' + title

        try:
            args = self.sub_commands[title]
            options_visitor = OptionsCheckVisitor(sub_cmd, args, self.document)
            node.walkabout(options_visitor)
            options_visitor.check_undocumented_arguments(
                {'--help', '--quiet', '--verbose', '-h', '-q', '-v'})
            del self.sub_commands[title]
        except KeyError:
            raise sphinx.errors.SphinxError(
                'No such sub-command {!r}'.format(sub_cmd)) 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:26,代碼來源:dochelpers.py

示例3: visit_desc_name

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def visit_desc_name(self, node):
        """ Checks if the option is defined `self.args` """
        if not isinstance(node[0], docutils.nodes.Text):
            raise sphinx.errors.SphinxError('first child should be Text')

        arg = str(node[0])
        try:
            self.args.remove(arg)
        except KeyError:
            raise sphinx.errors.SphinxError(
                'No such argument for {!r}: {!r}'.format(self.command, arg)) 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:13,代碼來源:dochelpers.py

示例4: check_undocumented_sub_commands

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def check_undocumented_sub_commands(self):
        """ Call this to check if any undocumented sub_commands are left.

            While the documentation talks about a
            'SparseNodeVisitor.depart_document()' function, this function does
            not exists. (For details see implementation of
            :py:meth:`NodeVisitor.dispatch_departure()`) So we need to
            manually call this.
        """
        if self.sub_commands:
            raise sphinx.errors.SphinxError(
                'Undocumented commands for {!r}: {!r}'.format(
                    self.command, ', '.join(sorted(self.sub_commands.keys())))) 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:15,代碼來源:dochelpers.py

示例5: __init__

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def __init__(self, app, command, document):
        docutils.nodes.SparseNodeVisitor.__init__(self, document)
        try:
            parser = qubes.tools.get_parser_for_command(command)
        except ImportError:
            msg = 'cannot import module for command'
            if log:
                log.warning(msg)
            else:
                # Handle legacy
                app.warn(msg)

            self.parser = None
            return
        except AttributeError:
            raise sphinx.errors.SphinxError('cannot find parser in module')

        self.command = command
        self.parser = parser
        self.options = set()
        self.sub_commands = {}
        self.app = app

        # pylint: disable=protected-access
        for action in parser._actions:
            if action.help == argparse.SUPPRESS:
                continue

            if issubclass(action.__class__,
                          qubes.tools.AliasedSubParsersAction):
                for cmd, cmd_parser in action._name_parser_map.items():
                    self.sub_commands[cmd] = set()
                    for sub_action in cmd_parser._actions:
                        if sub_action.help != argparse.SUPPRESS:
                            self.sub_commands[cmd].update(
                                sub_action.option_strings)
            else:
                self.options.update(action.option_strings) 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:40,代碼來源:dochelpers.py

示例6: __init__

# 需要導入模塊: import sphinx [as 別名]
# 或者: from sphinx import errors [as 別名]
def __init__(self, app, command, document):
        docutils.nodes.SparseNodeVisitor.__init__(self, document)
        try:
            parser = qubesadmin.tools.get_parser_for_command(command)
        except ImportError:
            msg = 'cannot import module for command'
            if log:
                log.warning(msg)
            else:
                # Handle legacy
                app.warn(msg)

            self.parser = None
            return
        except AttributeError:
            raise sphinx.errors.SphinxError('cannot find parser in module')

        self.command = command
        self.parser = parser
        self.options = set()
        self.sub_commands = {}
        self.app = app

        # pylint: disable=protected-access
        for action in parser._actions:
            if action.help == argparse.SUPPRESS:
                continue

            if issubclass(action.__class__,
                          qubesadmin.tools.AliasedSubParsersAction):
                for cmd, cmd_parser in action._name_parser_map.items():
                    self.sub_commands[cmd] = set()
                    for sub_action in cmd_parser._actions:
                        if sub_action.help != argparse.SUPPRESS:
                            self.sub_commands[cmd].update(
                                sub_action.option_strings)
            else:
                self.options.update(action.option_strings) 
開發者ID:QubesOS,項目名稱:qubes-core-admin-client,代碼行數:40,代碼來源:dochelpers.py


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