From 3690950850c388373870dd973ec12e1b8412ec0f Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sat, 1 Jan 2022 16:32:41 +0530 Subject: feat: generate config keys as pug --- tools/gen_config_doc.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/gen_config_doc.py b/tools/gen_config_doc.py index caedba577..98266386e 100644 --- a/tools/gen_config_doc.py +++ b/tools/gen_config_doc.py @@ -2,7 +2,7 @@ import re import os - +import argparse _KEYS_FILE = os.path.join( os.path.dirname(__file__), "../src/main/java/org/traccar/config/Keys.java" @@ -72,6 +72,31 @@ def get_html(): ) +def get_pug(): + return ("\n").join( + [ + f""" div(class='card mt-3') + div(class='card-body') + h5(class='card-title') {x["key"]} #[span(class='badge badge-dark') config] + p(class='card-text') {"#[br] ".join(x["description"])}""" + for x in get_config_keys() + ] + ) + + if __name__ == "__main__": - html = get_html() - print(html) + parser = argparse.ArgumentParser( + description="Parses Keys.java to extract keys to be used in configuration files" + ) + parser.add_argument( + "--format", choices=["pug", "html"], default="pug", help="default: 'pug'" + ) + args = parser.parse_args() + + def get_output(): + if args.format == 'html': + return get_html() + + return get_pug() + + print(get_output()) \ No newline at end of file -- cgit v1.2.3