mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +08:00
px_process_module_doc: add --no-validation flag
and make sure the command failed if there's a validation error.
This commit is contained in:
@@ -244,6 +244,7 @@ class SourceParser(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._modules = {} # all found modules: key is the module name
|
self._modules = {} # all found modules: key is the module name
|
||||||
|
self._consistency_checks_failure = False # one or more checks failed
|
||||||
|
|
||||||
def Parse(self, scope, contents):
|
def Parse(self, scope, contents):
|
||||||
"""
|
"""
|
||||||
@@ -336,6 +337,7 @@ class SourceParser(object):
|
|||||||
print("Warning: documentation inconsistency in %s:" % scope)
|
print("Warning: documentation inconsistency in %s:" % scope)
|
||||||
print(" Documented options : %s" % sorted_module_options)
|
print(" Documented options : %s" % sorted_module_options)
|
||||||
print(" Options found in getopt(): %s" % sorted_getopt_args)
|
print(" Options found in getopt(): %s" % sorted_getopt_args)
|
||||||
|
self._consistency_checks_failure = True
|
||||||
|
|
||||||
|
|
||||||
# now check the commands: search for strcmp(argv[i], "command".
|
# now check the commands: search for strcmp(argv[i], "command".
|
||||||
@@ -357,6 +359,7 @@ class SourceParser(object):
|
|||||||
|
|
||||||
if not command in doc_commands:
|
if not command in doc_commands:
|
||||||
print("Warning: undocumented command '%s' in %s" %(command, scope))
|
print("Warning: undocumented command '%s' in %s" %(command, scope))
|
||||||
|
self._consistency_checks_failure = True
|
||||||
|
|
||||||
|
|
||||||
def _parse_arguments(self, contents, start_index):
|
def _parse_arguments(self, contents, start_index):
|
||||||
@@ -438,6 +441,8 @@ class SourceParser(object):
|
|||||||
|
|
||||||
return next_position, args
|
return next_position, args
|
||||||
|
|
||||||
|
def HasValidationFailure(self):
|
||||||
|
return self._consistency_checks_failure
|
||||||
|
|
||||||
def GetModuleGroups(self):
|
def GetModuleGroups(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ def main():
|
|||||||
metavar="DIRECTORY",
|
metavar="DIRECTORY",
|
||||||
help="Markdown output directory"
|
help="Markdown output directory"
|
||||||
" (default DIRECTORY: .)")
|
" (default DIRECTORY: .)")
|
||||||
|
parser.add_argument('--no-validation', action='store_true', help="do not fail if consistency checks fail")
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', help="verbose output")
|
parser.add_argument('-v', '--verbose', action='store_true', help="verbose output")
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Check for valid command
|
# Check for valid command
|
||||||
@@ -84,8 +84,13 @@ def main():
|
|||||||
if not scanner.ScanDir(args.src_path, parser):
|
if not scanner.ScanDir(args.src_path, parser):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not args.no_validation and parser.HasValidationFailure():
|
||||||
|
print("Error: validation failed")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
module_groups = parser.GetModuleGroups()
|
module_groups = parser.GetModuleGroups()
|
||||||
|
|
||||||
|
|
||||||
# Output to Markdown/HTML tables
|
# Output to Markdown/HTML tables
|
||||||
if args.markdown:
|
if args.markdown:
|
||||||
out = markdownout.MarkdownTablesOutput(module_groups)
|
out = markdownout.MarkdownTablesOutput(module_groups)
|
||||||
|
|||||||
Reference in New Issue
Block a user