Skip to content

Commit fcf9bc5

Browse files
authored
add how to build the doc with devcontainer. (#4757)
* add how to build the doc with devcontainer. * use venv instead of virtualenv. * add venv to the official doc build procedure. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
1 parent c1161ad commit fcf9bc5

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"workspaceMount": "source=${localWorkspaceFolder},target=/tmp/doc_repository,type=bind",
77
"workspaceFolder": "/tmp/doc_repository",
8-
"postCreateCommand": "pip3 install --no-warn-script-location --user -r requirements.txt -c constraints.txt",
8+
"postCreateCommand": "pip3 install --no-warn-script-location --user -r requirements.txt -c constraints.txt --break-system-packages",
99
"features": {
1010
"ghcr.io/devcontainers/features/git:1": {}
1111
},

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@ To build this you need to install
1818

1919
* make
2020
* graphviz
21-
* python virtualenv
2221

23-
24-
In the virtualenv
22+
With [venv](https://docs.python.org/3/library/venv.html)
2523

2624
```
25+
# activate the venv
26+
python3 -m venv ros2doc
27+
28+
# activate venv
29+
source ros2doc/bin/activate
30+
31+
# install required packages
2732
pip install -r requirements.txt -c constraints.txt
33+
34+
# deactivate the venv
35+
(ros2doc) deactivate
2836
```
2937

3038
### Pinned versions
@@ -36,6 +44,7 @@ To upgrade the system validate that things are working and then use `pip freeze
3644
## Building HTML
3745

3846
### Local development test
47+
3948
For local testing of the current tree use:
4049

4150
`make html`

docker/image/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
#
44
# docker build -f docker/image/Dockerfile .
55

6-
FROM ubuntu:jammy
6+
FROM ubuntu:noble
77

88
ARG user=rosindex
99
ARG uid=1000
1010

1111
ENV DEBIAN_FRONTEND noninteractive
1212
ENV SHELL /bin/bash
1313

14+
# Delete user if it exists in container (e.g Ubuntu Noble: ubuntu)
15+
RUN if id -u $uid ; then userdel `id -un $uid` ; fi
16+
1417
RUN apt-get update && \
1518
apt-get install --no-install-recommends -y \
1619
git-all \
@@ -31,4 +34,4 @@ WORKDIR /tmp/doc_repository
3134

3235
USER $user
3336

34-
CMD pip3 install --no-warn-script-location --user -r requirements.txt -c constraints.txt && make multiversion
37+
CMD pip3 install --no-warn-script-location --user -r requirements.txt -c constraints.txt --break-system-packages && make multiversion

source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,37 @@ The root directory contains configuration and files required to locally build th
3333
Building the site locally
3434
-------------------------
3535

36-
Start by installing requirements located in the ``requirements.txt`` file:
36+
Start by creating `venv <https://docs.python.org/3/library/venv.html>`__ to build the documentation:
37+
38+
.. code-block:: console
39+
40+
# activate the venv
41+
python3 -m venv ros2doc
42+
43+
# activate venv
44+
source ros2doc/bin/activate
45+
46+
And install requirements located in the ``requirements.txt`` file:
3747

3848
.. tabs::
3949

4050
.. group-tab:: Linux
4151

42-
The next command does a user-specific install, which requires ``~/.local/bin/`` to be added to ``$PATH``:
43-
4452
.. code-block:: console
4553
46-
pip3 install --user --upgrade -r requirements.txt
54+
pip install -r requirements.txt -c constraints.txt
4755
4856
.. group-tab:: macOS
4957

5058
.. code-block:: console
5159
52-
pip3 install --user --upgrade -r requirements.txt
60+
pip install -r requirements.txt -c constraints.txt
5361
5462
.. group-tab:: Windows
5563

5664
.. code-block:: console
5765
58-
python -m pip install --user --upgrade -r requirements.txt
66+
python -m pip install -r requirements.txt -c constraints.txt
5967
6068
In order for Sphinx to be able to generate diagrams, the ``dot`` command must be available.
6169

@@ -232,6 +240,38 @@ Finally, to view the site, you can click on the "Go Live" button in the right bo
232240
:width: 100%
233241
:alt: Live Server
234242

243+
Building the Site with Devcontainer
244+
-----------------------------------
245+
246+
`ROS 2 Documentation GitHub repository <https://github.com/ros2/ros2_documentation>`__ also supports ``Devcontainer`` development environment with Visual Studio Code.
247+
This will enable you to build the documentation much easier without changing your operating system.
248+
249+
See :doc:`../../How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container` to install VS Code and Docker before the following procedure.
250+
251+
Clone repository and start VS Code:
252+
253+
.. code-block:: console
254+
255+
git clone https://github.com/ros2/ros2_documentation
256+
cd ./ros2_documentation
257+
code .
258+
259+
To use ``Devcontainer``, you need to install "Remote Development" Extension within VS Code search in Extensions (CTRL+SHIFT+X) for it.
260+
261+
And then, use ``View->Command Palette...`` or ``Ctrl+Shift+P`` to open the command palette.
262+
Search for the command ``Dev Containers: Reopen in Container`` and execute it.
263+
This will build your development docker container for you automatically.
264+
265+
To build the documentation, open a terminal using ``View->Terminal`` or ``Ctrl+Shift+``` and ``New Terminal`` in VS Code.
266+
Inside the terminal, you can build the documentation:
267+
268+
.. code-block:: console
269+
270+
make html
271+
272+
.. image:: images/vscode_devcontainer.png
273+
:width: 100%
274+
:alt: VS Code Devcontainer
235275

236276
Writing pages
237277
-------------
Loading

0 commit comments

Comments
 (0)