From 2fc4f408cd59930585ce48b574136c7ff1937a40 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 10 May 2016 20:26:54 +0200 Subject: [PATCH] Fix src2asciidoc --- qutebrowser/commands/command.py | 8 ++++---- scripts/dev/src2asciidoc.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 802d4a4bb..0e76cfd11 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -194,7 +194,7 @@ class Command: raise TypeError("{}: functions with varkw arguments are not " "supported!".format(self.name[0])) - def _get_arg_info(self, param): + def get_arg_info(self, param): """Get an ArgInfo tuple for the given inspect.Parameter.""" return self._qute_args.get(param.name, ArgInfo()) @@ -223,7 +223,7 @@ class Command: Return: True if the parameter is special, False otherwise. """ - arg_info = self._get_arg_info(param) + arg_info = self.get_arg_info(param) if arg_info.count: if param.default is inspect.Parameter.empty: raise TypeError("{}: handler has count parameter " @@ -318,7 +318,7 @@ class Command: """ args = [] name = arg_name(param.name) - arg_info = self._get_arg_info(param) + arg_info = self.get_arg_info(param) if arg_info.flag is not None: shortname = arg_info.flag @@ -467,7 +467,7 @@ class Command: return args, kwargs for i, param in enumerate(signature.parameters.values()): - arg_info = self._get_arg_info(param) + arg_info = self.get_arg_info(param) if i == 0 and self._instance is not None: # Special case for 'self'. self._get_self_arg(win_id, param, args) diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 78a639f20..1eaaf1192 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -218,14 +218,15 @@ def _get_command_doc_count(cmd, parser): Yield: Strings which should be added to the docs. """ - if cmd.count_arg is not None: - yield "" - yield "==== count" - try: - yield parser.arg_descs[cmd.count_arg] - except KeyError as e: - raise KeyError("No description for count arg {!r} of command " - "{!r}!".format(cmd.count_arg, cmd.name)) from e + for param in inspect.signature(cmd.handler).parameters.values(): + if cmd.get_arg_info(param).count: + yield "" + yield "==== count" + try: + yield parser.arg_descs[param.name] + except KeyError as e: + raise KeyError("No description for count arg {!r} of command " + "{!r}!".format(param.name, cmd.name)) from e def _get_command_doc_notes(cmd):