Skip to content

Commit eecc031

Browse files
committed
Adding mermaid diagram with dark mode.
1 parent b73b51a commit eecc031

5 files changed

Lines changed: 31 additions & 9 deletions

File tree

.readthedocs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ build:
1111
tools:
1212
python: "3.11"
1313
# You can also specify other tool versions:
14-
# nodejs: "19"
14+
nodejs: "19"
1515
# rust: "1.64"
1616
# golang: "1.19"
17+
jobs:
18+
post_install:
19+
- npm install -g @mermaid-js/mermaid-cli
1720

1821
# Build documentation in the docs/ directory with Sphinx
1922
sphinx:

docs/source/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
'hoverxref.extension', # https://sphinx-hoverxref.readthedocs.io/en/latest/index.html
3232
'sphinx_copybutton', # https://sphinx-copybutton.readthedocs.io/en/latest/
3333
'sphinx_design', # https://sphinx-design.readthedocs.io/en/latest/get_started.html
34-
"sphinxext.remoteliteralinclude" # https://github.com/wpilibsuite/sphinxext-remoteliteralinclude
35-
34+
'sphinxext.remoteliteralinclude', # https://github.com/wpilibsuite/sphinxext-remoteliteralinclude
35+
'sphinxcontrib.mermaid' #https://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest/
3636
]
3737

3838
intersphinx_mapping = {
@@ -60,6 +60,9 @@
6060
# -- Options for hoverxref.extension https://sphinx-hoverxref.readthedocs.io/en/latest/configuration.html
6161
hoverxref_auto_ref = True
6262

63+
# https://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest/
64+
mermaid_params = ['-p' 'puppeteer-config.json']
65+
6366
# -- Options for latex https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html
6467
# latex_engine = "xelatex"
6568
# By using this, the UTF emojis became question marks in the PDF.

docs/source/peppeteer-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"args": ["--no-sandbox"]
3+
}

docs/source/publishers_and_subscribers.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,30 @@ Publishers and Subscribers: using messages
55

66
Except for the particulars of the :file:`setup.py` file, the way that publishers and subscribers in ROS2 work in Python, i.e. the explanation in this section, does not depend on :program:`ament_python` or :program:`ament_cmake`.
77

8-
Finally, we reached the point where ROS2 becomes appealing. As you saw in the last section, we can easily create complex interface types using an easy and generic description.
8+
Finally, we reached the point where :program:`ROS2` becomes appealing. As you saw in the last section, we can easily create complex interface types using an easy and generic description.
99
We can use those to provide `interprocess communication <https://en.wikipedia.org/wiki/Inter-process_communication>`_, i.e. two different programs talking to each other, which otherwise can be error-prone and very difficult to implement.
1010

11-
ROS2 works on a model in which any number of processes can communicate over a :code:`Topic` that only accepts one message type. Each topic is uniquely identified by a string.
11+
:program:`ROS2` messages work on a model in which any number of processes can communicate over a :code:`Topic` that only accepts one message type. Each topic is uniquely identified by a string.
1212

1313
Then
1414

15-
- A program that sends (publishes) information to the topic has a :code:`Publisher`.
16-
- A program that reads (subscribes) information from a topic has a :code:`Subscriber`.
15+
- A program that sends (publishes) information to the topic has one or more :code:`Publisher` \(s).
16+
- A program that reads (subscribes) information from a topic has one or more :code:`Subscriber` \(s).
1717

18-
Each Node can have any number of :code:`Publishers` and :code:`Subscribers` and a combination thereof, connecting to an arbitrary number of Nodes. This forms part of the connections in the so-called `ROS graph <https://docs.ros.org/en/humble/Concepts.html#quick-overview-of-ros-2-concepts>`_.
18+
Each Node can have any number of :code:`Publishers` and :code:`Subscribers` and a combination thereof, connecting to an arbitrary number of Nodes. This forms part of the connections in the so-called `ROS graph <https://docs.ros.org/en/humble/Concepts.html#quick-overview-of-ros-2-concepts>`_. An example is shown below.
19+
20+
.. mermaid::
21+
22+
%%{init: { "theme" : "dark" }}%%
23+
graph LR;
24+
A[Publisher #1] --> B[Topic]
25+
C[Publisher #2] --> B
26+
B --> D[Subscriber #1]
27+
28+
.. note::
29+
30+
This is an abstraction. As long as the information flows in this manner, it does not mean that an entity called ``topic`` must exist.
31+
In :program:`ROS2`, this type of communication happens, in fact, peer-to-peer.
1932

2033
Create the package
2134
------------------

docs/source/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ sphinx-design
44
sphinx-rtd-theme
55
sphinxext-remoteliteralinclude
66
sphinx-book-theme
7-
sphinxcontrib-globalsubs
7+
sphinxcontrib-mermaid

0 commit comments

Comments
 (0)