diff --git a/tools/config-markdown.py b/tools/config-markdown.py index b897c0565..fa60a2f25 100755 --- a/tools/config-markdown.py +++ b/tools/config-markdown.py @@ -4,8 +4,29 @@ import sys import json import argparse +import re from pathlib import Path +def extract_module_options_from_sh_files(directory): + module_options = {} + + sh_files = Path(directory).glob("*.sh") + pattern = re.compile(r'\[\s*"(?P[^"]+?),(?P[^"]+?)"\s*\]\s*=\s*"(?P[^"]*?)"') + + for sh_file in sh_files: + with open(sh_file, 'r', encoding='utf-8') as f: + content = f.read() + for match in pattern.finditer(content): + module = match.group("module") + key = match.group("key") + value = match.group("value") + + if module not in module_options: + module_options[module] = {} + module_options[module][key] = value + + return module_options + # Setup paths SCRIPT_DIR = Path(__file__).resolve().parent CONFIG_PATH = SCRIPT_DIR.parent / 'lib' / 'armbian-config' / 'config.jobs.json' @@ -13,6 +34,9 @@ MARKDOWN_DIR = SCRIPT_DIR / 'include' / 'markdown' DOCS_DIR = Path('docs') +# Add this line to load it at runtime +module_options = extract_module_options_from_sh_files(str(SCRIPT_DIR.parent / 'lib' / 'armbian-config')) + # Load JSON if not CONFIG_PATH.exists(): print("Error: The configuration file 'config.jobs.json' was not found.") @@ -99,10 +123,28 @@ def create_markdown_user(item, level=1, show_meta=True, force_title=False, skip_ if sub_item.get('short') and sub_item.get('description') and sub_item.get('short') != sub_item.get('description'): md.append(f"\n{sub_item.get('description')}\n") md.extend(insert_images_and_header(sub_item)) - if sub_item.get('author'): - md.append(f"**Author:** {sub_item['author']}\n") + #if sub_item.get('author'): + # md.append(f"__Author:__ {sub_item['author']} ") + if sub_item.get('module'): + module = sub_item['module'] + if module in module_options: + maintainer = module_options[module].get('maintainer') + if maintainer: + md.append(f"__Maintainer:__ {maintainer} ") if sub_item.get('status'): - md.append(f"**Status:** {sub_item['status']}\n") + md.append(f"__Status:__ {sub_item['status']} ") + if sub_item.get('module'): + module = sub_item['module'] + if module in module_options: + doc_link = module_options[module].get('arch') + if doc_link: + md.append(f"__Architecture:__ {doc_link} ") + if sub_item.get('module'): + module = sub_item['module'] + if module in module_options: + doc_link = module_options[module].get('doc_link') + if doc_link: + md.append(f"__Documentation:__ [Link]({doc_link}) ") first_sub = False if sub_item.get('command'): diff --git a/tools/json/config.software.json b/tools/json/config.software.json index 200345995..d19784d2f 100644 --- a/tools/json/config.software.json +++ b/tools/json/config.software.json @@ -12,6 +12,7 @@ "id": "SWAG01", "description": "SWAG reverse proxy", "short": "SWAG", + "module": "module_swag", "command": [ "module_swag install" ], @@ -59,6 +60,7 @@ "id": "HAB001", "description": "openHAB empowering the smart home", "short": "openHAB", + "module": "module_openhab", "about": "This operation will install openHAB.", "command": [ "module_openhab install" @@ -127,6 +129,7 @@ "id": "DOM001", "description": "Domoticz open source home automation", "short": "Domoticz", + "module": "module_domoticz", "about": "This operation will install Domoticz.", "command": [ "module_domoticz install" @@ -161,6 +164,7 @@ "id": "EVCC01", "description": "EVCC - solar charging automation", "short": "EVCC", + "module": "module_evcc", "about": "This operation will install solar charging automation.", "command": [ "module_evcc install" @@ -201,6 +205,7 @@ "id": "PIH001", "description": "Pi-hole DNS ad blocker", "short": "Pi-hole", + "module": "module_pi_hole", "command": [ "module_pi_hole install" ], @@ -242,6 +247,7 @@ "id": "UNB001", "description": "Unbound caching DNS resolver", "short": "Unbound", + "module": "module_unbound", "command": [ "module_unbound install" ], @@ -273,6 +279,7 @@ "id": "ADG001", "description": "AdGuardHome DNS sinkhole", "short": "AdGuardHome", + "module": "module_adguardhome", "command": [ "module_adguardhome install" ], @@ -310,6 +317,7 @@ "id": "NAV001", "description": "Navidrome music server and streamer compatible with Subsonic/Airsonic", "short": "Navidrome", + "module": "module_navidrome", "command": [ "module_navidrome install" ], @@ -347,6 +355,7 @@ "id": "ABU001", "description": "Do your finances with Actual Budget", "short": "Actual Budget", + "module": "module_actualbudget", "command": [ "module_actualbudget install" ], @@ -635,6 +644,7 @@ "id": "DPL001", "description": "Duplicati install", "short": "Duplicati", + "module": "module_duplicati", "about": "This operation will install Duplicati backup software", "command": [ "module_duplicati install" @@ -1089,6 +1099,7 @@ "id": "PGSQL1", "description": "PostgreSQL install", "short": "PostgreSQL", + "module": "module_postgres", "about": "This operation will install PostgreSQL, an advanced relational database server", "command": [ "module_postgres install" @@ -1123,6 +1134,7 @@ "id": "DAT001", "description": "Mariadb SQL database server", "short": "Mariadb", + "module": "module_mariadb", "command": [ "module_mariadb install" ], @@ -1154,6 +1166,7 @@ "id": "REDIS1", "description": "Redis install", "short": "Redis", + "module": "module_redis", "about": "This operation will install Redis, a powerful in-memory key-value database", "command": [ "module_redis install" @@ -1188,6 +1201,7 @@ "id": "MYA001", "description": "phpMyAdmin web interface manager", "short": "phpMyAdmin", + "module": "module_phpmyadmin", "command": [ "module_phpmyadmin install" ], @@ -1333,6 +1347,7 @@ "id": "CON001", "description": "Docker minimal", "short": "Docker", + "module": "module_docker", "about": "This operation will install Docker Minimal.", "command": [ "module_docker install minimal" @@ -1378,6 +1393,7 @@ "id": "POR001", "description": "Portainer container management platform", "short": "Portainer", + "module": "module_portainer", "prompt": "This operation will install Portainer container management platform.", "command": [ "module_portainer install" @@ -1440,6 +1456,7 @@ "id": "EMB001", "description": "Emby organizes video, music, live TV, and photos", "short": "Emby", + "module": "module_embyserver", "about": "This operation will install Emby server.", "command": [ "module_embyserver install" @@ -1702,6 +1719,7 @@ "id": "UPK001", "description": "Uptime Kuma self-hosted monitoring tool", "short": "Uptime Kuma", + "module": "module_uptimekuma", "about": "This operation will install Uptime Kuma", "command": [ "module_uptimekuma install"