Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MeadeCommandParser.py #254

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions scripts/MeadeCommandParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand All @@ -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("<br>\n\n")
Expand Down
Loading