ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Where are the recommended formatting rules of package.xml?

asked 2021-07-03 04:15:29 -0500

Kenji Miyake gravatar image

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.

However, I couldn't find the rules in REP 149. (I'm sorry if I overlooked them.)

Where are the rules written? Although I can guess it from package_format3.xsd, I want a more clear explanation.

Also, is there any way to check the rule automatically? I think ament_xmllint doesn't support it.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-08-24 04:30:48 -0500

Kenji Miyake gravatar image

updated 2021-08-24 04:31:24 -0500

We developed https://github.com/tier4/pre-commit-h... to automatically format package.xml.

edit flag offensive delete link more

Comments

+100 for making this available.

It's not the answer to your question though :)

gvdhoorn gravatar image gvdhoorn  ( 2021-08-24 04:35:13 -0500 )edit

Thank you for adding your star so soon! :-) Please remember that this is tested only with our limited use cases yet.

It's not the answer to your question though :)

Okay, removed.

Kenji Miyake gravatar image Kenji Miyake  ( 2021-08-24 05:02:13 -0500 )edit
0

answered 2021-07-03 04:20:44 -0500

gvdhoorn gravatar image

updated 2021-07-03 04:35:11 -0500

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-07-03 04:15:29 -0500

Seen: 68 times

Last updated: Aug 24 '21