From b924fd4642dbad6ef17daca33c36ccd7196e7556 Mon Sep 17 00:00:00 2001 From: Marko Durkovic Date: Mon, 11 Apr 2022 14:10:38 +0200 Subject: [PATCH] Add documentation for included types --- docs/api/rosbags.rst | 1 + docs/api/rosbags.typesys.types.rst | 6 + docs/conf.py | 1 + docs/topics/typesys-types.rst | 194 +++++++++++++++++++++++++++++ docs/topics/typesys.rst | 5 + src/rosbags/typesys/__main__.py | 16 +++ 6 files changed, 223 insertions(+) create mode 100644 docs/api/rosbags.typesys.types.rst create mode 100644 docs/topics/typesys-types.rst diff --git a/docs/api/rosbags.rst b/docs/api/rosbags.rst index 19c8a4f3..e8761f70 100644 --- a/docs/api/rosbags.rst +++ b/docs/api/rosbags.rst @@ -9,3 +9,4 @@ Rosbags namespace rosbags.rosbag2 rosbags.serde rosbags.typesys + rosbags.typesys.types diff --git a/docs/api/rosbags.typesys.types.rst b/docs/api/rosbags.typesys.types.rst new file mode 100644 index 00000000..46b5d243 --- /dev/null +++ b/docs/api/rosbags.typesys.types.rst @@ -0,0 +1,6 @@ +rosbags.typesys.types +===================== + +.. automodule:: rosbags.typesys.types + :members: + :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py index 17b2ed43..ace01c87 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,6 +22,7 @@ copyright = '2020-2022, Ternaris' author = 'Ternaris' autoapi_python_use_implicit_namespaces = True +autodoc_typehints = 'description' extensions = [ 'sphinx.ext.autodoc', diff --git a/docs/topics/typesys-types.rst b/docs/topics/typesys-types.rst new file mode 100644 index 00000000..6c8cfb60 --- /dev/null +++ b/docs/topics/typesys-types.rst @@ -0,0 +1,194 @@ +builtin_interfaces +****************** +- :py:class:`Duration ` +- :py:class:`Time ` + +diagnostic_msgs +*************** +- :py:class:`DiagnosticArray ` +- :py:class:`DiagnosticStatus ` +- :py:class:`KeyValue ` + +geometry_msgs +************* +- :py:class:`Accel ` +- :py:class:`AccelStamped ` +- :py:class:`AccelWithCovariance ` +- :py:class:`AccelWithCovarianceStamped ` +- :py:class:`Inertia ` +- :py:class:`InertiaStamped ` +- :py:class:`Point ` +- :py:class:`Point32 ` +- :py:class:`PointStamped ` +- :py:class:`Polygon ` +- :py:class:`PolygonStamped ` +- :py:class:`Pose ` +- :py:class:`Pose2D ` +- :py:class:`PoseArray ` +- :py:class:`PoseStamped ` +- :py:class:`PoseWithCovariance ` +- :py:class:`PoseWithCovarianceStamped ` +- :py:class:`Quaternion ` +- :py:class:`QuaternionStamped ` +- :py:class:`Transform ` +- :py:class:`TransformStamped ` +- :py:class:`Twist ` +- :py:class:`TwistStamped ` +- :py:class:`TwistWithCovariance ` +- :py:class:`TwistWithCovarianceStamped ` +- :py:class:`Vector3 ` +- :py:class:`Vector3Stamped ` +- :py:class:`Wrench ` +- :py:class:`WrenchStamped ` + +libstatistics_collector +*********************** +- :py:class:`DummyMessage ` + +lifecycle_msgs +************** +- :py:class:`State ` +- :py:class:`Transition ` +- :py:class:`TransitionDescription ` +- :py:class:`TransitionEvent ` + +nav_msgs +******** +- :py:class:`GridCells ` +- :py:class:`MapMetaData ` +- :py:class:`OccupancyGrid ` +- :py:class:`Odometry ` +- :py:class:`Path ` + +rcl_interfaces +************** +- :py:class:`FloatingPointRange ` +- :py:class:`IntegerRange ` +- :py:class:`ListParametersResult ` +- :py:class:`Log ` +- :py:class:`Parameter ` +- :py:class:`ParameterDescriptor ` +- :py:class:`ParameterEvent ` +- :py:class:`ParameterEventDescriptors ` +- :py:class:`ParameterType ` +- :py:class:`ParameterValue ` +- :py:class:`SetParametersResult ` + +rmw_dds_common +************** +- :py:class:`Gid ` +- :py:class:`NodeEntitiesInfo ` +- :py:class:`ParticipantEntitiesInfo ` + +rosgraph_msgs +************* +- :py:class:`Clock ` + +sensor_msgs +*********** +- :py:class:`BatteryState ` +- :py:class:`CameraInfo ` +- :py:class:`ChannelFloat32 ` +- :py:class:`CompressedImage ` +- :py:class:`FluidPressure ` +- :py:class:`Illuminance ` +- :py:class:`Image ` +- :py:class:`Imu ` +- :py:class:`JointState ` +- :py:class:`Joy ` +- :py:class:`JoyFeedback ` +- :py:class:`JoyFeedbackArray ` +- :py:class:`LaserEcho ` +- :py:class:`LaserScan ` +- :py:class:`MagneticField ` +- :py:class:`MultiDOFJointState ` +- :py:class:`MultiEchoLaserScan ` +- :py:class:`NavSatFix ` +- :py:class:`NavSatStatus ` +- :py:class:`PointCloud ` +- :py:class:`PointCloud2 ` +- :py:class:`PointField ` +- :py:class:`Range ` +- :py:class:`RegionOfInterest ` +- :py:class:`RelativeHumidity ` +- :py:class:`Temperature ` +- :py:class:`TimeReference ` + +shape_msgs +********** +- :py:class:`Mesh ` +- :py:class:`MeshTriangle ` +- :py:class:`Plane ` +- :py:class:`SolidPrimitive ` + +statistics_msgs +*************** +- :py:class:`MetricsMessage ` +- :py:class:`StatisticDataPoint ` +- :py:class:`StatisticDataType ` + +std_msgs +******** +- :py:class:`Bool ` +- :py:class:`Byte ` +- :py:class:`ByteMultiArray ` +- :py:class:`Char ` +- :py:class:`ColorRGBA ` +- :py:class:`Empty ` +- :py:class:`Float32 ` +- :py:class:`Float32MultiArray ` +- :py:class:`Float64 ` +- :py:class:`Float64MultiArray ` +- :py:class:`Header ` +- :py:class:`Int16 ` +- :py:class:`Int16MultiArray ` +- :py:class:`Int32 ` +- :py:class:`Int32MultiArray ` +- :py:class:`Int64 ` +- :py:class:`Int64MultiArray ` +- :py:class:`Int8 ` +- :py:class:`Int8MultiArray ` +- :py:class:`MultiArrayDimension ` +- :py:class:`MultiArrayLayout ` +- :py:class:`String ` +- :py:class:`UInt16 ` +- :py:class:`UInt16MultiArray ` +- :py:class:`UInt32 ` +- :py:class:`UInt32MultiArray ` +- :py:class:`UInt64 ` +- :py:class:`UInt64MultiArray ` +- :py:class:`UInt8 ` +- :py:class:`UInt8MultiArray ` + +stereo_msgs +*********** +- :py:class:`DisparityImage ` + +tf2_msgs +******** +- :py:class:`TF2Error ` +- :py:class:`TFMessage ` + +trajectory_msgs +*************** +- :py:class:`JointTrajectory ` +- :py:class:`JointTrajectoryPoint ` +- :py:class:`MultiDOFJointTrajectory ` +- :py:class:`MultiDOFJointTrajectoryPoint ` + +unique_identifier_msgs +********************** +- :py:class:`UUID ` + +visualization_msgs +****************** +- :py:class:`ImageMarker ` +- :py:class:`InteractiveMarker ` +- :py:class:`InteractiveMarkerControl ` +- :py:class:`InteractiveMarkerFeedback ` +- :py:class:`InteractiveMarkerInit ` +- :py:class:`InteractiveMarkerPose ` +- :py:class:`InteractiveMarkerUpdate ` +- :py:class:`Marker ` +- :py:class:`MarkerArray ` +- :py:class:`MenuEntry ` diff --git a/docs/topics/typesys.rst b/docs/topics/typesys.rst index 26c19274..b846adc4 100644 --- a/docs/topics/typesys.rst +++ b/docs/topics/typesys.rst @@ -13,6 +13,11 @@ The type system generates a dataclass for each message type. These dataclasses g Limitation: While the type system parses message definitions with array bounds and/or default values, neither bounds nor default values are enforced or assigned to message instances. +Included message types +---------------------- + +.. include:: ./typesys-types.rst + Extending the type system ------------------------- Adding custom message types consists of two steps. First, message definitions are converted into parse trees using :py:func:`get_types_from_idl() ` or :py:func:`get_types_from_msg() `, and second the types are registered in the type system via :py:func:`register_types() `. The following example shows how to add messages type definitions from ``.msg`` and ``.idl`` files: diff --git a/src/rosbags/typesys/__main__.py b/src/rosbags/typesys/__main__.py index 5f9f957f..f7dd37ff 100644 --- a/src/rosbags/typesys/__main__.py +++ b/src/rosbags/typesys/__main__.py @@ -4,6 +4,7 @@ from __future__ import annotations +from itertools import groupby from os import walk from pathlib import Path from typing import TYPE_CHECKING @@ -16,6 +17,19 @@ if TYPE_CHECKING: from .base import Typesdict +def generate_docs(typs: Typesdict) -> str: + """Generate types documentation.""" + res = [] + for namespace, msgs in groupby([x.split('/msg/') for x in typs], key=lambda x: x[0]): + res.append(namespace) + res.append('*' * len(namespace)) + + for _, msg in msgs: + res.append(f'- :py:class:`{msg} `') + res.append('') + return '\n'.join(res) + + def main() -> None: # pragma: no cover """Update builtin types. @@ -24,6 +38,7 @@ def main() -> None: # pragma: no cover """ typs: Typesdict = {} selfdir = Path(__file__).parent + projectdir = selfdir.parent.parent.parent for root, dirnames, files in walk(selfdir.parents[2] / 'tools' / 'messages'): if '.rosbags_ignore' in files: dirnames.clear() @@ -40,6 +55,7 @@ def main() -> None: # pragma: no cover typs = dict(sorted(typs.items())) register_types(typs) (selfdir / 'types.py').write_text(generate_python_code(typs)) + (projectdir / 'docs' / 'topics' / 'typesys-types.rst').write_text(generate_docs(typs)) if __name__ == '__main__':