Skip to content

Commit 6c139ca

Browse files
Update MeadeCommandParser.py (#254)
Co-authored-by: Lutz <lutz@stmuc.com>
1 parent 03af68a commit 6c139ca

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

scripts/MeadeCommandParser.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import os
1212
import re
1313

14-
MEADE_HPP = "..\\src\\MeadeCommandProcessor.cpp"
14+
MEADE_CPP = "..\\src\\MeadeCommandProcessor.cpp"
15+
VERSION_FILE = "..\\Version.h"
1516
MODULE_PATH = os.path.dirname(os.path.realpath(__file__))
1617
START_LINE = 0
1718
END_LINE = 0
@@ -122,8 +123,13 @@ def check_command_sepparator(line):
122123
else:
123124
return False
124125

125-
# Meade hpp File
126-
with open(os.path.join(MODULE_PATH, MEADE_HPP)) as f:
126+
127+
# ***************************************************************
128+
# PARSE MEADE COMMANDS
129+
# ***************************************************************
130+
131+
# Meade cpp File
132+
with open(os.path.join(MODULE_PATH, MEADE_CPP)) as f:
127133
content = f.readlines()
128134
content = [x.strip() for x in content]
129135

@@ -226,6 +232,24 @@ def check_command_sepparator(line):
226232
new_family.commands.append(command)
227233
all_commands.append(new_family)
228234

235+
# ***************************************************************
236+
# PARSE MEADE COMMANDS
237+
# ***************************************************************
238+
CURRENT_VERSION = "0.0"
239+
with open(os.path.join(MODULE_PATH, VERSION_FILE)) as f:
240+
version_content = f.readlines()
241+
version_content = [x.strip() for x in version_content]
242+
243+
for line in version_content:
244+
if "#define VERSION" in line:
245+
CURRENT_VERSION = line.replace("#define VERSION ", "")
246+
CURRENT_VERSION = CURRENT_VERSION.replace("\"", "")
247+
print(f"Found current version: {CURRENT_VERSION}")
248+
249+
if CURRENT_VERSION == "0.0":
250+
raise Exception("Could not find current version to parse from")
251+
252+
229253
def output_wiki():
230254
"""
231255
Writes content to a MeadeToWikiOutput.txt file
@@ -236,6 +260,9 @@ def output_wiki():
236260
for fam in all_commands:
237261
f.write("> AUTOMATICALLY GENERATED FROM FIRMWARE - DO NOT EDIT\n")
238262
f.write("{.is-danger}\n\n")
263+
264+
f.write(f"> This documentation is current as of Firmware **{CURRENT_VERSION}**\n")
265+
f.write("{.is-warning}\n\n")
239266

240267
f.write(f"## {fam.name}\n")
241268
f.write("<br>\n\n")

0 commit comments

Comments
 (0)