Skip to content

Commit

Permalink
Improve documentation (#277)
Browse files Browse the repository at this point in the history
* Add Sphinx docs
* Document node.py
* Fix C extension documentation
* Document init, shutdown, and spinning
* Document Publisher and Subscription
* Document Client and Service
* Add warnings to constructors of client and service
* Document executors and callback groups
  * Use typing,TYPE_CHECKING variable for condition imports used by annotations.
* Fix mypy errors
* Add instructions for building docs to README
* Clarify doc briefs for graph discovery functions

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
  • Loading branch information
jacobperron committed Mar 12, 2019
1 parent 0184628 commit e9cc80c
Show file tree
Hide file tree
Showing 30 changed files with 1,211 additions and 229 deletions.
14 changes: 14 additions & 0 deletions README.md
@@ -1,2 +1,16 @@
# rclpy
ROS Client Library for the Python language.

## Building documentation

Documentation can be built for `rclpy` using [Sphinx](http://www.sphinx-doc.org/en/master/).

#### Install dependencies

sudo apt install python3-sphinx python3-pip
sudo -H pip3 install sphinx_autodoc_typehints

#### Build

cd rclpy/docs
make html
19 changes: 19 additions & 0 deletions rclpy/docs/Makefile
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions rclpy/docs/make.bat
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
7 changes: 7 additions & 0 deletions rclpy/docs/source/about.rst
@@ -0,0 +1,7 @@
About
=====

The canonical Python API for `ROS 2 <https://index.ros.org/doc/ros2>`_.

*rclpy* is built on the common C-API provided by `rcl <https://github.com/ros2/rcl>`_.

22 changes: 22 additions & 0 deletions rclpy/docs/source/api.rst
@@ -0,0 +1,22 @@
API
===

.. toctree::
:maxdepth: 2
:caption: Contents:

api/init_shutdown
api/node
api/topics
api/services
api/actions
api/timers
api/parameters
api/logging
api/context
api/execution_and_callbacks
api/utilities
api/qos

.. TODO(jacobperron): Document remaining API
api/time
11 changes: 11 additions & 0 deletions rclpy/docs/source/api/actions.rst
@@ -0,0 +1,11 @@
Actions
=======

Action Client
-------------

.. automodule:: rclpy.action.client

Action Server
-------------
.. automodule:: rclpy.action.server
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/context.rst
@@ -0,0 +1,4 @@
Context
=======

.. automodule:: rclpy.context
18 changes: 18 additions & 0 deletions rclpy/docs/source/api/execution_and_callbacks.rst
@@ -0,0 +1,18 @@
Execution and Callbacks
=======================

There are two components that control the execution of callbacks: **executors** and **callback groups**.

Executors are responsible for the actual execution of callbacks and should extend the :class:`.Executor` class.

Callback groups are used to enforce concurrency rules for callbacks and should extend the :class:`.CallbackGroup` class.

Executors
---------

.. automodule:: rclpy.executors


Callback Groups
---------------
.. automodule:: rclpy.callback_groups
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/init_shutdown.rst
@@ -0,0 +1,4 @@
Initialization, Shutdown, and Spinning
======================================

.. automodule:: rclpy
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/logging.rst
@@ -0,0 +1,4 @@
Logging
=======

.. automodule:: rclpy.logging
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/node.rst
@@ -0,0 +1,4 @@
Node
====

.. automodule:: rclpy.node
12 changes: 12 additions & 0 deletions rclpy/docs/source/api/parameters.rst
@@ -0,0 +1,12 @@
Parameters
==========

Parameter
---------

.. automodule:: rclpy.parameter

Parameter Service
-----------------

.. automodule:: rclpy.parameter_service
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/qos.rst
@@ -0,0 +1,4 @@
Quality of Service
==================

.. automodule:: rclpy.qos
12 changes: 12 additions & 0 deletions rclpy/docs/source/api/services.rst
@@ -0,0 +1,12 @@
Services
========

Client
------

.. automodule:: rclpy.client

Service
-------

.. automodule:: rclpy.service
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/timers.rst
@@ -0,0 +1,4 @@
Timer
=====

.. automodule:: rclpy.timer
12 changes: 12 additions & 0 deletions rclpy/docs/source/api/topics.rst
@@ -0,0 +1,12 @@
Topics
======

Publisher
---------

.. automodule:: rclpy.publisher

Subscription
------------

.. automodule:: rclpy.subscription
4 changes: 4 additions & 0 deletions rclpy/docs/source/api/utilities.rst
@@ -0,0 +1,4 @@
Utilities
=========

.. automodule:: rclpy.utilities

0 comments on commit e9cc80c

Please sign in to comment.