From 70f9184898f4e8683a9fac6125413b07670af85c Mon Sep 17 00:00:00 2001 From: Martin K Date: Sat, 11 Jun 2022 02:27:06 +0300 Subject: [PATCH 1/3] Help: Change default function documentation --- pymine/logic/cmds/help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/cmds/help.py b/pymine/logic/cmds/help.py index 917990ec..44931df5 100644 --- a/pymine/logic/cmds/help.py +++ b/pymine/logic/cmds/help.py @@ -37,4 +37,4 @@ async def help(uuid: str): for name, command in server.api.commands._commands.items(): func, node = command doc = getattr(func, "__doc__") - server.console.info(f"{name}: {'A command.' if doc is None else doc}") + server.console.info(f"{name}: {'Documentation missing.' if doc is None else doc}") From 30d91fd877c53528f0220b5d5df3d1a604b66165 Mon Sep 17 00:00:00 2001 From: Martin K Date: Sat, 11 Jun 2022 02:51:39 +0300 Subject: [PATCH 2/3] Help: Display arguments and their types --- pymine/logic/cmds/help.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pymine/logic/cmds/help.py b/pymine/logic/cmds/help.py index 44931df5..fc84dec2 100644 --- a/pymine/logic/cmds/help.py +++ b/pymine/logic/cmds/help.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import inspect import os from pymine.server import server @@ -38,3 +39,24 @@ async def help(uuid: str): func, node = command doc = getattr(func, "__doc__") server.console.info(f"{name}: {'Documentation missing.' if doc is None else doc}") + + if func.__code__.co_argcount > 1: + server.console.info(" Arguments:") + argspec = inspect.getfullargspec(func) + + for arg in argspec.args[1:]: # Skipping the first 'uuid' + # look at this mess + ann = ( + ( + ": " + + ( + argspec.annotations[arg].__name__ + if hasattr(argspec.annotations[arg], "__name__") + else argspec.annotations[arg].__class__.__name__ + ) + ) + if arg in argspec.annotations.keys() + else "" + ) + + server.console.info(" - " + arg + ann) From 8f66acd05c282e4eee2bc18082ea30456026e290 Mon Sep 17 00:00:00 2001 From: Martin K Date: Sat, 11 Jun 2022 02:57:32 +0300 Subject: [PATCH 3/3] Help: XXX comment --- pymine/logic/cmds/help.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymine/logic/cmds/help.py b/pymine/logic/cmds/help.py index fc84dec2..971af8f2 100644 --- a/pymine/logic/cmds/help.py +++ b/pymine/logic/cmds/help.py @@ -44,6 +44,7 @@ async def help(uuid: str): server.console.info(" Arguments:") argspec = inspect.getfullargspec(func) + # XXX: Causes errors / incorrect behaviour if you introduce other mandatory arguments for arg in argspec.args[1:]: # Skipping the first 'uuid' # look at this mess ann = (