Seeing existing ROS packages, it seems there are some rules for formatting package.xml.
- There should be a new line between mandatory and optional tags.
- There should be a new line when the
depend
type has changed.
Your question seems to be about formatting of the file contents.
There are no real guidelines or requirements for that specifically -- or at least, not that I'm aware of.
As it's XML, formatting doesn't matter, as long as it's valid XML.
Adding newlines and other formatting would only help humans, and the manifest is mostly meant for machine consumption (hence the use of XML).
And I know you tagged this ros2
, but just for reference:
Also, is there any way to check the rule automatically?
Some aspects of a package manifest can be checked automatically, at least in ROS 1. catkin_lint is a tool which checks for consistency between a package's build script and package.xml
contents. It also checks compliance with (some parts of) the REP you mention (and its previous versions).
catkin_lint
does not support ROS 2 right now, so that won't help you directly, but I thought to mention it.
I think ament_xmllint
doesn't support it.
IIRC, ament_xmllint
only checks whether the files passed are valid XML. It uses xmllint
, which will parse the XML and complain about any violations (against a schema for instance).
File formatting (as long as it doesn't prevent parsing of the file) is not checked.