Add macros to link to interface docs #5050
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is currently more of a proof of concept, so it's a draft while I request feedback.
While reviewing #5034, I realized/remembered that we now have interface (e.g., message) docs in ROS 2 like we had in ROS 1:
Having this for ROS 2 is quite useful, and we can use it in many places instead of linking to the source files, like we currently do in this tutorial (and others).
However, I also realized that the path was a bit different depending on the distro, see #5034 (comment). While that is probably just a result of a different version of
rosdoc2
being used for different distros at possibly different times (seerosdoc2/verbs/build/generate_interface_docs.py
), I think we could abstract the link away from the documentation writer using macros similar to the ones we currently have.This PR introduces two macros: (1)
interface_link()
and (2)interface()
. They each take the interface name as a parameter and expand to the (1) the link to the interface doc page and (2) the interface name hyperlinked to its interface doc page.{interface_link(std_msgs/msg/String)}
See: {interface_link(std_msgs/msg/String)}.
{interface(std_msgs/msg/String)}
Publish a {interface(std_msgs/msg/String)}.
(*) formatted as markdown in this PR description for demonstration purposes, but the result is the same
interface()
exists for simples links with the interface name only, whileinterface_link()
could be used anywhere, including more complex RST links, such as:See the changes to
source/Tutorials/Intermediate/Publishing-Messages-Using-YAML-Files.rst
for a concrete example.This is valid for messages, services, and actions:
Notes:
interface_link_templ
) could be customized for each distro like we do for the existing macros.literal
, although we could find a way around it, especially if we hide away the ugly details.Future work:
.py
file