Skip to content

Commit 30c22bf

Browse files
committed
Tools: legacy-param options for param_parse.py
1 parent a8b57dc commit 30c22bf

File tree

8 files changed

+35
-3
lines changed

8 files changed

+35
-3
lines changed

Tools/autotest/param_metadata/ednemit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def start_libraries(self):
3434

3535
def emit(self, g):
3636
for param in g.params:
37+
if not self.should_emit_param(param):
38+
continue
3739
output_dict = dict()
3840
# lowercase all keywords
3941
for key in param.__dict__.keys():

Tools/autotest/param_metadata/emit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(self):
1010
pass
1111

1212
prog_values_field = re.compile(r"-?\d*\.?\d+: ?[\w ]+,?")
13+
emit_legacy_params = True
1314

1415
def close(self):
1516
pass
@@ -20,5 +21,10 @@ def start_libraries(self):
2021
def emit(self, g):
2122
pass
2223

24+
def should_emit_param(self, param):
25+
if not self.emit_legacy_params and getattr(param, 'Legacy', False):
26+
return False
27+
return True
28+
2329
def should_emit_field(self, param, field):
2430
return field not in ['Legacy']

Tools/autotest/param_metadata/htmlemit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def emit(self, g):
5656
t = '\n\n<h1>%s</h1>\n' % tag
5757

5858
for param in g.params:
59+
if not self.should_emit_param(param):
60+
continue
5961
if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):
6062
continue
6163
d = param.__dict__

Tools/autotest/param_metadata/jsonemit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def emit(self, g):
3636

3737
# Check all params available
3838
for param in g.params:
39+
if not self.should_emit_param(param):
40+
continue
3941
param_json = {}
4042

4143
# Get display name

Tools/autotest/param_metadata/mdemit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def emit(self, g):
7979
t = '\n\n# %s' % tag
8080

8181
for param in g.params:
82+
if not self.should_emit_param(param):
83+
continue
8284
if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):
8385
continue
8486
d = param.__dict__

Tools/autotest/param_metadata/param_parse.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
action='store_false',
3131
default=True,
3232
help="don't emit parameter documentation, just validate")
33+
parser.add_argument("--legacy-params",
34+
dest='emit_legacy_params',
35+
action='store_true',
36+
default=None,
37+
help="include legacy parameters in output (default depends on format)")
38+
parser.add_argument("--no-legacy-params",
39+
dest='emit_legacy_params',
40+
action='store_false',
41+
default=None,
42+
help="don't include legacy parameters in output (default depends on format)")
3343
parser.add_argument("--format",
3444
dest='output_format',
3545
action='store',
@@ -39,7 +49,6 @@
3949

4050
args = parser.parse_args()
4151

42-
4352
# Regular expressions for parsing the parameter metadata
4453

4554
prog_param = re.compile(r"@Param(?:{([^}]+)})?: (\w+).*((?:\n[ \t]*// @(\w+)(?:{([^}]+)})?: ?(.*))+)(?:\n[ \t\r]*\n|\n[ \t]+[A-Z]|\n\-\-\]\])", re.MULTILINE) # noqa
@@ -713,6 +722,14 @@ def validate(param, is_library=False):
713722
for emitter_name in emitters_to_use:
714723
emit = all_emitters[emitter_name]()
715724

725+
emit.emit_legacy_params = args.emit_legacy_params
726+
if emit.emit_legacy_params is None:
727+
if emitter_name in ('rst', 'rstlatexpdf'):
728+
# do not emit legacy parameters to the Wiki
729+
emit.emit_legacy_params = False
730+
else:
731+
emit.emit_legacy_params = True
732+
716733
emit.emit(vehicle)
717734

718735
emit.start_libraries()

Tools/autotest/param_metadata/rstemit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ def emit(self, g):
227227
reference=reference)
228228

229229
for param in g.params:
230-
if getattr(param, "Legacy", False):
231-
# do not emit legacy parameters to the Wiki
230+
if not self.should_emit_param(param):
232231
continue
233232
if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):
234233
continue

Tools/autotest/param_metadata/xmlemit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def emit(self, g):
8484
xml_parameters = etree.SubElement(self.current_element, 'parameters', name=g.reference) # i.e. ArduPlane
8585

8686
for param in g.params:
87+
if not self.should_emit_param(param):
88+
continue
8789
# Begin our parameter node
8890
if hasattr(param, 'DisplayName'):
8991
xml_param = etree.SubElement(xml_parameters, 'param', humanName=param.DisplayName, name=param.name) # i.e. ArduPlane (ArduPlane:FOOPARM)

0 commit comments

Comments
 (0)