From 1a96ae512c99792eda6fd05ca4f514ebefc032cc Mon Sep 17 00:00:00 2001 From: "R. Kent James" Date: Tue, 26 Mar 2024 21:07:19 -0700 Subject: [PATCH] Fix issues, add action support --- rosdoc2/verbs/build/builders/sphinx_builder.py | 6 ++++++ rosdoc2/verbs/build/generate_interface_docs.py | 6 ++---- test/packages/full_package/action/Fibonacci.action | 11 +++++++++++ test/test_builder.py | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/packages/full_package/action/Fibonacci.action diff --git a/rosdoc2/verbs/build/builders/sphinx_builder.py b/rosdoc2/verbs/build/builders/sphinx_builder.py index 54784c2..27ec246 100644 --- a/rosdoc2/verbs/build/builders/sphinx_builder.py +++ b/rosdoc2/verbs/build/builders/sphinx_builder.py @@ -43,6 +43,10 @@ def generate_package_toc_entry(*, build_context, interface_counts) -> str: # inside the string to fall under the `:toctree:` directive toc_entry_cpp = ' C++ API \n' toc_entry_py = ' Python API \n' + toc_entry_msg = ' Message Definitions \n' + toc_entry_srv = ' Service Definitions \n' + toc_entry_action = ' Action Definitions \n' + toc_entry = '\n' if build_type == 'ament_python' or always_run_sphinx_apidoc or ament_cmake_python: @@ -53,6 +57,8 @@ def generate_package_toc_entry(*, build_context, interface_counts) -> str: toc_entry += toc_entry_msg if interface_counts['srv'] > 0: toc_entry += toc_entry_srv + if interface_counts['action'] > 0: + toc_entry += toc_entry_action return toc_entry diff --git a/rosdoc2/verbs/build/generate_interface_docs.py b/rosdoc2/verbs/build/generate_interface_docs.py index 242e263..8e1457d 100644 --- a/rosdoc2/verbs/build/generate_interface_docs.py +++ b/rosdoc2/verbs/build/generate_interface_docs.py @@ -13,13 +13,11 @@ # limitations under the License. -"""Generate rst files for messages and services.""" +"""Generate rst files for messages, services, and actions.""" import fnmatch import os -# from jinja2 import Template - iface_fm_rst = """\ {iface_name} {name_underline} @@ -64,7 +62,7 @@ def generate_interface_docs(path: str, package: str, output_dir: str): :rtype: dict(str, int) """ counts = {} - for type_info in (('msg', 'message'), ('srv', 'service')): + for type_info in (('msg', 'message'), ('srv', 'service'), ('action', 'action')): count = 0 (type_ext, type_name) = type_info interfaces = _find_files_with_extension(path, type_ext) diff --git a/test/packages/full_package/action/Fibonacci.action b/test/packages/full_package/action/Fibonacci.action new file mode 100644 index 0000000..e360e9d --- /dev/null +++ b/test/packages/full_package/action/Fibonacci.action @@ -0,0 +1,11 @@ +# This action is based on the action tutorial +# https://docs.ros.org/en/rolling/Tutorials/Intermediate/Creating-an-Action.html + +# order of the Fibonacci sequence we want to compute +int32 order +--- +# the final result +int32[] sequence +--- +# feedback of what is completed so far +int32[] partial_sequence diff --git a/test/test_builder.py b/test/test_builder.py index 060ae25..d585bb0 100644 --- a/test/test_builder.py +++ b/test/test_builder.py @@ -195,6 +195,9 @@ def test_full_package(session_dir): PKG_NAME, 'python api', 'c++ api', + 'message definitions', + 'service definitions', + 'action definitions' ] file_includes = [ 'generated/index.html'