mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 23:13:35 +08:00
parameters delete unused scope
This commit is contained in:
@@ -1 +1 @@
|
|||||||
__all__ = ["srcscanner", "srcparser", "xmlout", "scope"]
|
__all__ = ["srcscanner", "srcparser", "xmlout"]
|
||||||
|
|||||||
@@ -8,16 +8,6 @@ class MarkdownTablesOutput():
|
|||||||
"\n")
|
"\n")
|
||||||
for group in groups:
|
for group in groups:
|
||||||
result += '## %s\n\n' % group.GetName()
|
result += '## %s\n\n' % group.GetName()
|
||||||
|
|
||||||
#Check if scope (module where parameter is defined) is the same for all parameters in the group.
|
|
||||||
# If so then display just once about the table.
|
|
||||||
scope_set = set()
|
|
||||||
for param in group.GetParams():
|
|
||||||
scope_set.add(param.GetFieldValue("scope"))
|
|
||||||
if len(scope_set)==1:
|
|
||||||
result+='\nThe module where these parameters are defined is: *%s*.\n\n' % list(scope_set)[0]
|
|
||||||
|
|
||||||
|
|
||||||
result += '<table style="width: 100%; table-layout:fixed; font-size:1.5rem; overflow: auto; display:block;">\n'
|
result += '<table style="width: 100%; table-layout:fixed; font-size:1.5rem; overflow: auto; display:block;">\n'
|
||||||
result += ' <colgroup><col style="width: 23%"><col style="width: 46%"><col style="width: 11%"><col style="width: 11%"><col style="width: 9%"></colgroup>\n'
|
result += ' <colgroup><col style="width: 23%"><col style="width: 46%"><col style="width: 11%"><col style="width: 11%"><col style="width: 9%"></colgroup>\n'
|
||||||
result += ' <thead>\n'
|
result += ' <thead>\n'
|
||||||
@@ -64,13 +54,6 @@ class MarkdownTablesOutput():
|
|||||||
if reboot_required:
|
if reboot_required:
|
||||||
reboot_required='<p><b>Reboot required:</b> %s</p>\n' % reboot_required
|
reboot_required='<p><b>Reboot required:</b> %s</p>\n' % reboot_required
|
||||||
|
|
||||||
scope=''
|
|
||||||
if not len(scope_set)==1 or len(scope_set)==0:
|
|
||||||
scope = param.GetFieldValue("scope") or ''
|
|
||||||
if scope:
|
|
||||||
scope='<p><b>Module:</b> %s</p>\n' % scope
|
|
||||||
|
|
||||||
|
|
||||||
enum_codes=param.GetEnumCodes() or '' # Gets numerical values for parameter.
|
enum_codes=param.GetEnumCodes() or '' # Gets numerical values for parameter.
|
||||||
enum_output=''
|
enum_output=''
|
||||||
# Format codes and their descriptions for display.
|
# Format codes and their descriptions for display.
|
||||||
@@ -93,7 +76,7 @@ class MarkdownTablesOutput():
|
|||||||
bitmask_output+='</ul>\n'
|
bitmask_output+='</ul>\n'
|
||||||
|
|
||||||
|
|
||||||
result += '<tr>\n <td style="vertical-align: top;">%s (%s)</td>\n <td style="vertical-align: top;"><p>%s</p>%s %s %s %s %s</td>\n <td style="vertical-align: top;">%s</td>\n <td style="vertical-align: top;">%s </td>\n <td style="vertical-align: top;">%s</td>\n</tr>\n' % (code,type,name, long_desc, enum_output, bitmask_output, reboot_required, scope, max_min_combined,def_val,unit)
|
result += '<tr>\n <td style="vertical-align: top;">%s (%s)</td>\n <td style="vertical-align: top;"><p>%s</p>%s %s %s %s</td>\n <td style="vertical-align: top;">%s</td>\n <td style="vertical-align: top;">%s </td>\n <td style="vertical-align: top;">%s</td>\n</tr>\n' % (code, type, name, long_desc, enum_output, bitmask_output, reboot_required, max_min_combined, def_val, unit)
|
||||||
|
|
||||||
#Close the table.
|
#Close the table.
|
||||||
result += '</tbody></table>\n\n'
|
result += '</tbody></table>\n\n'
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
class Scope(object):
|
|
||||||
"""
|
|
||||||
Single parameter group
|
|
||||||
"""
|
|
||||||
re_deep_lines = re.compile(r'.*\/.*\/')
|
|
||||||
def __init__(self,):
|
|
||||||
self.scope = set()
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.scope.__str__()
|
|
||||||
|
|
||||||
def Add(self, scope):
|
|
||||||
"""
|
|
||||||
Add Scope to set
|
|
||||||
"""
|
|
||||||
self.scope.add(scope)
|
|
||||||
|
|
||||||
def Has(self, scope):
|
|
||||||
"""
|
|
||||||
Check for existance
|
|
||||||
"""
|
|
||||||
if len(self.scope) == 0:
|
|
||||||
return True
|
|
||||||
# Anything in the form xxxxx/yyyyy/zzzzz....
|
|
||||||
# is treated as xxxxx/yyyyy
|
|
||||||
while (self.re_deep_lines.match(scope)):
|
|
||||||
scope = os.path.dirname(scope)
|
|
||||||
return scope in self.scope
|
|
||||||
@@ -186,7 +186,7 @@ class SourceParser(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.param_groups = {}
|
self.param_groups = {}
|
||||||
|
|
||||||
def Parse(self, scope, contents):
|
def Parse(self, contents):
|
||||||
"""
|
"""
|
||||||
Incrementally parse program contents and append all found parameters
|
Incrementally parse program contents and append all found parameters
|
||||||
to the list.
|
to the list.
|
||||||
@@ -288,7 +288,6 @@ class SourceParser(object):
|
|||||||
if defval != "" and self.re_is_a_number.match(defval):
|
if defval != "" and self.re_is_a_number.match(defval):
|
||||||
defval = self.re_cut_type_specifier.sub('', defval)
|
defval = self.re_cut_type_specifier.sub('', defval)
|
||||||
param = Parameter(name, tp, defval)
|
param = Parameter(name, tp, defval)
|
||||||
param.SetField("scope", scope)
|
|
||||||
param.SetField("short_desc", name)
|
param.SetField("short_desc", name)
|
||||||
# If comment was found before the parameter declaration,
|
# If comment was found before the parameter declaration,
|
||||||
# inject its data into the newly created parameter.
|
# inject its data into the newly created parameter.
|
||||||
|
|||||||
@@ -34,11 +34,6 @@ class SourceScanner(object):
|
|||||||
Scans provided file and passes its contents to the parser using
|
Scans provided file and passes its contents to the parser using
|
||||||
parser.Parse method.
|
parser.Parse method.
|
||||||
"""
|
"""
|
||||||
# Extract the scope: it is the directory within the repo. Either it
|
|
||||||
# starts directly with 'src/module/abc', or it has the form 'x/y/z/src/module/abc'.
|
|
||||||
# The output is 'module/abc' in both cases.
|
|
||||||
prefix = "^(|.*" + os.path.sep + ")src" + os.path.sep
|
|
||||||
scope = re.sub(prefix.replace("\\", "/"), "", os.path.dirname(os.path.relpath(path)).replace("\\", "/"))
|
|
||||||
|
|
||||||
with codecs.open(path, 'r', 'utf-8') as f:
|
with codecs.open(path, 'r', 'utf-8') as f:
|
||||||
try:
|
try:
|
||||||
@@ -47,4 +42,4 @@ class SourceScanner(object):
|
|||||||
contents = ''
|
contents = ''
|
||||||
print('Failed reading file: %s, skipping content.' % path)
|
print('Failed reading file: %s, skipping content.' % path)
|
||||||
pass
|
pass
|
||||||
return parser.Parse(scope, contents)
|
return parser.Parse(contents)
|
||||||
|
|||||||
Reference in New Issue
Block a user