-
Notifications
You must be signed in to change notification settings - Fork 97
Documentation for MAV_CMD variants #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Adds parsing for params into the MavProfile data structure. Add a table of paramters to all MAV_CMD variants including description, valid values and unit. Change xml parser to use expand_empty_elements=true, this removed a lot of duplicate code and prevents a some of potential bugs.
onur-ozkan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A snapshot test coverage would be nice.
| match (self.min_value, self.max_value, self.increment) { | ||
| (Some(min), Some(max), Some(inc)) => { | ||
| if min + inc == max { | ||
| format!("{min}, {max}") | ||
| } else if min + 2. * inc == max { | ||
| format!("{}, {}, {}", min, min + inc, max) | ||
| } else { | ||
| format!("{}, {}, .. , {}", min, min + inc, max) | ||
| } | ||
| } | ||
| (Some(min), Some(max), None) => format!("{min} .. {max}"), | ||
| (Some(min), None, Some(inc)) => format!("{}, {}, .. ", min, min + inc), | ||
| (Some(min), None, None) => format!("≥ {min}"), | ||
| (None, Some(max), Some(inc)) => format!(".. , {}, {}", max - inc, max), | ||
| (None, Some(max), None) => format!("≤ {max}"), | ||
| (None, None, Some(inc)) => format!("Multiples of {inc}"), | ||
| (None, None, _) => String::new(), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very hard to follow and debug. Also, moving lines would change the behavior significantly (which is dangerous). Can we somehow re-write this in a better and safer way?
| } | ||
| params[param_index - 1] = MavParam { | ||
| index: param_index, | ||
| description: param_description.unwrap_or_default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not making description Option<String as well?
MAV_CMD should get better support that the current method of manually having to fill the paramters fields. This adds the XML parsing part and used it for documentation but can later be used for codegen too.
Also simplify the XML parsing by treating self closing tags as an start and end tag, the self closing tag handling had just copied code anyways. This should also avoid some bugs like #393.
Example of new doc:
