From 789e06c12231ac9f7d850de8975b76fc0aa3833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Nizio?= Date: Mon, 6 Aug 2018 22:39:42 +0200 Subject: [PATCH] [solo.commands.command, equo] support "authors" in docs Suggested by Ettore. My comment is that it is to have a more correct information and to give credit where it is due. This is not a "miscredit" towards the Creator. We know who has made this possible! --- client/doc/generate | 6 +++++- client/solo/commands/command.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/doc/generate b/client/doc/generate index 967d45f31..f08e72590 100755 --- a/client/doc/generate +++ b/client/doc/generate @@ -94,7 +94,7 @@ OPTIONS AUTHORS ------- -Fabio Erculiani (lxnay@sabayon.org) +%(authors)s REPORTING BUGS -------------- @@ -136,6 +136,10 @@ for descriptor in descriptors: man['seealso'] = "" else: man['seealso'] = ", " + man['seealso'] + + if not man['authors']: + man['authors'] = "Fabio Erculiani " + man_txt = SPLIT_MAN % man split_mans.append((man['name'], man_txt)) diff --git a/client/solo/commands/command.py b/client/solo/commands/command.py index 6ae6535b5..fd391ccf7 100644 --- a/client/solo/commands/command.py +++ b/client/solo/commands/command.py @@ -10,6 +10,7 @@ """ import os +import re import sys import argparse @@ -237,6 +238,18 @@ class SoloCommand(object): stdout.write(" ".join(available_args) + "\n") stdout.flush() + def _get_authors(self): + """ + Function to pull authors of a command from module's docstring. + """ + authors = [] + module = sys.modules[self.__module__] + for x in module.__doc__.splitlines(): + m = re.match(r" *@author: *(.+)\s*$", x) + if m: + authors.append(m.group(1)) + return authors + def man(self): """ Return a dictionary containing the following man @@ -308,6 +321,7 @@ class SoloCommand(object): 'seealso': self.SEE_ALSO, 'synopsis': usage, 'options': "\n".join(options_txt), + 'authors': "\n".join(self._get_authors()) } return data