From 58a03fc53ce0f1caaadbdd2812ce3144315fa1c2 Mon Sep 17 00:00:00 2001 From: toitoinebzh Date: Thu, 14 Mar 2019 00:22:18 +0100 Subject: [PATCH] Script to generate manpages - Fix #284 --- manpages_auto.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 manpages_auto.py diff --git a/manpages_auto.py b/manpages_auto.py new file mode 100644 index 000000000..077aba963 --- /dev/null +++ b/manpages_auto.py @@ -0,0 +1,43 @@ + GNU nano 2.7.4 FichierĀ : manpages_auto.py + +""" +Inspired by yunohost_completion.py (author: Christophe Vuillot) +======= + +This script generates man pages for yunohost. +Pages are stored in OUTPUT_DIR +""" + +import yaml +import os + +ACTIONSMAP_FILE = '/usr/share/moulinette/actionsmap/yunohost.yml' +OUTPUT_DIR ="output/" + +# creates output directory +os.system("mkdir "+ OUTPUT_DIR ) + + +# man page of yunohost +cmd = "sudo help2man \" yunohost \" -o " + OUTPUT_DIR + "yunohost" +print(cmd) +os.system(cmd) + +# man pages of "yunohost *" +with open(ACTIONSMAP_FILE, 'r') as stream: + + # Getting the dictionary containning what actions are possible per domain + OPTION_TREE = yaml.load(stream) + DOMAINS = [str for str in OPTION_TREE.keys() if not str.startswith('_')] + DOMAINS_STR = '"{}"'.format(' '.join(DOMAINS)) + ACTIONS_DICT = {} + for domain in DOMAINS: + ACTIONS = [str for str in OPTION_TREE[domain]['actions'].keys() + if not str.startswith('_')] + ACTIONS_STR = '"{}"'.format(' '.join(ACTIONS)) + ACTIONS_DICT[domain] = ACTIONS_STR + for action in ACTIONS: + #print("yunohost", domain, action) + cmd = "sudo help2man \" yunohost " + domain + " " + action + " --help \" -o " +$ + print(cmd) + os.system(cmd)