Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
firmware
scripts
param_parser.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
#
3
__author__ =
"James Jackson"
4
__copyright__ =
"Copyright 2017, ROSflight"
5
__license__ =
"BSD-3"
6
__version__ =
"0.1"
7
__maintainer__ =
"James Jackson"
8
__email__ =
"superjax08@gmail.com"
9
10
import
re
11
12
f = open(
'../src/param.cpp'
)
13
text = f.read()
14
15
16
lines = re.split(
"\n+"
, text)
17
18
params = []
19
i = 0
20
for
line
in
lines:
21
# search for init_param lines
22
match = re.search(
"^\s*init_param"
, line)
23
if
match !=
None
:
24
name_with_quotes = re.search(
"\".*\""
, line).group(0)
25
name = re.search(
"\w{1,16}"
, name_with_quotes).group(0)
26
if
name !=
'DEFAULT'
:
27
params.append(dict())
28
params[i][
'type'
] = re.split(
"\("
, re.split(
"_"
, line)[2])[0]
29
params[i][
'name'
] = name
30
# Find default value
31
params[i][
'default'
] = re.split(
"\)"
, re.split(
","
, line)[2])[0]
32
# isolate the comment portion of the line and split it on the "|" characters
33
comment = re.split(
"\|"
, re.split(
"//"
, line)[1])
34
# Isolate the Description
35
params[i][
"description"
] = comment[0].strip()
36
params[i][
"min"
] = comment[1].strip()
37
params[i][
"max"
] = comment[2].strip()
38
i += 1
39
40
# Now, generate the markdown table of the parameters
41
out = open(
'parameter-descriptions.md'
,
'w'
)
42
# Print the title
43
out.write(
"# Parameter descriptions\n\n"
)
44
# Start the table
45
out.write(
"| Parameter | Description | Type | Default Value | Min | Max |\n"
)
46
out.write(
"|-----------|-------------|------|---------------|-----|-----|\n"
)
47
for
param
in
params:
48
out.write(
"| "
)
49
out.write(param[
'name'
])
50
out.write(
" | "
)
51
out.write(param[
'description'
])
52
out.write(
" | "
)
53
out.write(param[
'type'
])
54
out.write(
" | "
)
55
out.write(param[
'default'
])
56
out.write(
" | "
)
57
out.write(param[
'min'
])
58
out.write(
" | "
)
59
out.write(param[
'max'
])
60
out.write(
" |\n"
)
61
62
out.close()
63
64
debug = 1
rosflight_firmware
Author(s): Daniel Koch
, James Jackson
autogenerated on Thu Apr 15 2021 05:07:47