From 5b57d7bc6ad3120a90a392129cf61d7833a43994 Mon Sep 17 00:00:00 2001 From: Sylvan Le Deunff Date: Sat, 24 Oct 2020 17:28:50 +0200 Subject: [PATCH 1/2] Display only first row of command docstring --- hug/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hug/api.py b/hug/api.py index 7179c7a4..82a92f2d 100644 --- a/hug/api.py +++ b/hug/api.py @@ -472,7 +472,7 @@ def __str__(self): output = "{0}\n\nAvailable Commands:\n\n".format(self.api.doc or self.api.name) for command_name, command in self.commands.items(): command_string = " - {}{}".format( - command_name, ": " + str(command).replace("\n", " ") if str(command) else "" + command_name, ": " + str(command).split('\n')[0] if str(command) else "" ) output += command_string[:77] + "..." if len(command_string) > 80 else command_string output += "\n" From bfacf76f8feba65374a904c1090d67bb82a5b502 Mon Sep 17 00:00:00 2001 From: Sylvan Le Deunff Date: Sat, 24 Oct 2020 17:30:22 +0200 Subject: [PATCH 2/2] Align docstring based on command_name length --- hug/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hug/api.py b/hug/api.py index 82a92f2d..7a6886d0 100644 --- a/hug/api.py +++ b/hug/api.py @@ -470,9 +470,10 @@ def output_format(self, formatter): def __str__(self): output = "{0}\n\nAvailable Commands:\n\n".format(self.api.doc or self.api.name) + max_length = max((len(command_name) for command_name in self.commands)) for command_name, command in self.commands.items(): command_string = " - {}{}".format( - command_name, ": " + str(command).split('\n')[0] if str(command) else "" + command_name.ljust(max_length+3), str(command).split('\n')[0] if str(command) else "" ) output += command_string[:77] + "..." if len(command_string) > 80 else command_string output += "\n"