mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
msg_docs: fix IndexError crash and camel_to_snake regex (#26546)
Fix generate_msg_docs.py IndexError when a .msg file declares a single topic that does not match the camel_to_snake default (e.g. AuxGlobalPosition.msg). The error message referenced self.topics[1] (out of bounds) instead of self.topics[0]. Fix camel_to_snake() regex to correctly convert names like "AuxGlobalPosition" to "aux_global_position". The previous regex produced "aux_globalposition" because it failed to insert an underscore between a lowercase letter and an uppercase letter mid-word. Also remove stderr redirection (2>&1) from all make targets in metadata_sync.sh so that errors are visible in CI logs even in non-verbose mode, making failures easier to diagnose. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
parent
9fb0ff0e80
commit
9048a40277
@ -123,7 +123,7 @@ generate_parameters() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make parameters_metadata
|
||||
else
|
||||
make parameters_metadata >/dev/null 2>&1
|
||||
make parameters_metadata >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ generate_airframes() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make airframe_metadata
|
||||
else
|
||||
make airframe_metadata >/dev/null 2>&1
|
||||
make airframe_metadata >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ generate_modules() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make module_documentation
|
||||
else
|
||||
make module_documentation >/dev/null 2>&1
|
||||
make module_documentation >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ generate_msg_docs() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make msg_docs
|
||||
else
|
||||
make msg_docs >/dev/null 2>&1
|
||||
make msg_docs >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ generate_uorb_graphs() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make uorb_graphs
|
||||
else
|
||||
make uorb_graphs >/dev/null 2>&1
|
||||
make uorb_graphs >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ generate_failsafe_web() {
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
make failsafe_web
|
||||
else
|
||||
make failsafe_web >/dev/null 2>&1
|
||||
make failsafe_web >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -729,10 +729,10 @@ pageClass: is-wide-page
|
||||
|
||||
# Fix up topics if the topic is empty
|
||||
def camel_to_snake(name):
|
||||
# Match upper case not at start of string
|
||||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
# Handle cases with multiple capital first letter
|
||||
return re.sub('([A-Z]+)([A-Z][a-z]*)', r'\1_\2', s1).lower()
|
||||
# Insert underscore between lowercase/digit and uppercase letter
|
||||
s1 = re.sub('([a-z0-9])([A-Z])', r'\1_\2', name)
|
||||
# Insert underscore between consecutive uppercase and uppercase+lowercase
|
||||
return re.sub('([A-Z]+)([A-Z][a-z])', r'\1_\2', s1).lower()
|
||||
|
||||
defaultTopic = camel_to_snake(self.name)
|
||||
if len(self.topics) == 0:
|
||||
@ -745,7 +745,7 @@ pageClass: is-wide-page
|
||||
error = Error("topic_error", self.filename, "", f"WARNING: TOPIC {defaultTopic} unnecessarily declared for {self.name}")
|
||||
else:
|
||||
# Declared topic is not default topic
|
||||
error = Error("topic_error", self.filename, "", f"NOTE: TOPIC {self.topics[1]}: Only Declared topic is not default topic {defaultTopic} for {self.name}")
|
||||
error = Error("topic_error", self.filename, "", f"NOTE: TOPIC {self.topics[0]}: Only Declared topic is not default topic {defaultTopic} for {self.name}")
|
||||
if not "topic_error" in self.errors:
|
||||
self.errors["topic_error"] = []
|
||||
self.errors["topic_error"].append(error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user