From a4d78c27c405aa30c1257e1e7488583d28403c7b Mon Sep 17 00:00:00 2001 From: Christian Kardach Date: Wed, 6 Nov 2024 22:53:51 +0100 Subject: [PATCH] Update MeadeCommandParser.py Parsing the current firmware version from ./Version.h onto the top of the page --- scripts/MeadeCommandParser.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/scripts/MeadeCommandParser.py b/scripts/MeadeCommandParser.py index 22524f3d..e3214c2c 100644 --- a/scripts/MeadeCommandParser.py +++ b/scripts/MeadeCommandParser.py @@ -11,7 +11,8 @@ import os import re -MEADE_HPP = "..\\src\\MeadeCommandProcessor.cpp" +MEADE_CPP = "..\\src\\MeadeCommandProcessor.cpp" +VERSION_FILE = "..\\Version.h" MODULE_PATH = os.path.dirname(os.path.realpath(__file__)) START_LINE = 0 END_LINE = 0 @@ -122,8 +123,13 @@ def check_command_sepparator(line): else: return False -# Meade hpp File -with open(os.path.join(MODULE_PATH, MEADE_HPP)) as f: + +# *************************************************************** +# PARSE MEADE COMMANDS +# *************************************************************** + +# Meade cpp File +with open(os.path.join(MODULE_PATH, MEADE_CPP)) as f: content = f.readlines() content = [x.strip() for x in content] @@ -226,6 +232,24 @@ def check_command_sepparator(line): new_family.commands.append(command) all_commands.append(new_family) +# *************************************************************** +# PARSE MEADE COMMANDS +# *************************************************************** +CURRENT_VERSION = "0.0" +with open(os.path.join(MODULE_PATH, VERSION_FILE)) as f: + version_content = f.readlines() +version_content = [x.strip() for x in version_content] + +for line in version_content: + if "#define VERSION" in line: + CURRENT_VERSION = line.replace("#define VERSION ", "") + CURRENT_VERSION = CURRENT_VERSION.replace("\"", "") + print(f"Found current version: {CURRENT_VERSION}") + +if CURRENT_VERSION == "0.0": + raise Exception("Could not find current version to parse from") + + def output_wiki(): """ Writes content to a MeadeToWikiOutput.txt file @@ -236,6 +260,9 @@ def output_wiki(): for fam in all_commands: f.write("> AUTOMATICALLY GENERATED FROM FIRMWARE - DO NOT EDIT\n") f.write("{.is-danger}\n\n") + + f.write(f"> This documentation is current as of Firmware **{CURRENT_VERSION}**\n") + f.write("{.is-warning}\n\n") f.write(f"## {fam.name}\n") f.write("
\n\n")