Python sphinx.errors() Examples
The following are 10
code examples of sphinx.errors().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sphinx
, or try the search function
.
Example #1
Source File: dochelpers.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 6 votes |
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))))
Example #2
Source File: dochelpers.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 6 votes |
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))
Example #3
Source File: dochelpers.py From qubes-core-admin-client with GNU Lesser General Public License v2.1 | 6 votes |
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))))
Example #4
Source File: dochelpers.py From qubes-core-admin-client with GNU Lesser General Public License v2.1 | 6 votes |
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))
Example #5
Source File: dochelpers.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 5 votes |
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))
Example #6
Source File: dochelpers.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 5 votes |
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()))))
Example #7
Source File: dochelpers.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 5 votes |
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)
Example #8
Source File: dochelpers.py From qubes-core-admin-client with GNU Lesser General Public License v2.1 | 5 votes |
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))
Example #9
Source File: dochelpers.py From qubes-core-admin-client with GNU Lesser General Public License v2.1 | 5 votes |
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()))))
Example #10
Source File: dochelpers.py From qubes-core-admin-client with GNU Lesser General Public License v2.1 | 5 votes |
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)