yunohost/manpages_auto.py
2019-06-02 04:30:46 +02:00

43 lines
1.3 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)