Skip to content

Commit 11392bc

Browse files
build: update workflows to use markdown-autodocs for improved documentation synchronization
1 parent b5da0d5 commit 11392bc

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

.github/workflows/rust-minimal.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@ jobs:
3535
container:
3636
image: ${{ matrix.docker_image }}
3737
steps:
38-
- uses: actions/checkout@v2
38+
- name: Markdown autodocs
39+
- uses: dineshsonachalam/markdown-autodocs@v1.0.7
3940
with:
40-
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
41-
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
42-
ref: refs/heads/${{ github.head_ref }}
43-
44-
- uses: technology-studio-forks/markdown-embed-code@main
45-
with:
46-
markdown: "docs/writing-your-first-rclrs-node.md"
47-
token: ${{ secrets.GITHUB_TOKEN }}
48-
message: "synchronizing Markdown files"
49-
silent: false
41+
commit_message: Synchronizing Markdown files
42+
branch: ${{ github.head_ref }}
43+
output_file_paths: '[./docs/writing-your-first-rclrs-node.md]'
44+
categories: '[code-block]'
5045

5146
- name: Search packages in this repository
5247
id: list_packages

.github/workflows/rust-stable.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@ jobs:
3535
container:
3636
image: ${{ matrix.docker_image }}
3737
steps:
38-
- uses: actions/checkout@v2
38+
- name: Markdown autodocs
39+
- uses: dineshsonachalam/markdown-autodocs@v1.0.7
3940
with:
40-
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
41-
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
42-
ref: refs/heads/${{ github.head_ref }}
43-
44-
- uses: technology-studio-forks/markdown-embed-code@main
45-
with:
46-
markdown: "docs/writing-your-first-rclrs-node.md"
47-
token: ${{ secrets.GITHUB_TOKEN }}
48-
message: "synchronizing Markdown files"
49-
silent: false
41+
commit_message: Synchronizing Markdown files
42+
branch: ${{ github.head_ref }}
43+
output_file_paths: '[./docs/writing-your-first-rclrs-node.md]'
44+
categories: '[code-block]'
5045

5146
- name: Search packages in this repository
5247
id: list_packages

docs/writing-your-first-rclrs-node.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,26 @@ If you couldn't follow the explanation involving borrowing, closures etc. above,
148148

149149
The node still doesn't republish the received messages. First, let's add a publisher to the node:
150150

151-
```rust:examples/minimal_pub_sub/src/first_rclrs_node.rs [5-10]
151+
```
152+
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../examples/minimal_pub_sub/src/first_rclrs_node.rs&lines=5-10) -->
153+
<!-- MARKDOWN-AUTO-DOCS:END -->
152154
```
153155

154156
Create a publisher and add it to the newly instantiated `RepublisherNode`:
155157

156-
```rust:examples/minimal_pub_sub/src/first_rclrs_node.rs [23-29]
157158
```
159+
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../examples/minimal_pub_sub/src/first_rclrs_node.rs&lines=23-29) -->
160+
<!-- MARKDOWN-AUTO-DOCS:END -->
161+
```
162+
158163

159164
Then, let's add a `republish()` function to the `RepublisherNode` that publishes the latest message received, or does nothing if none was received:
160165

161-
```rust:examples/minimal_pub_sub/src/first_rclrs_node.rs [32-37]
162166
```
167+
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../examples/minimal_pub_sub/src/first_rclrs_node.rs&lines=32-37) -->
168+
<!-- MARKDOWN-AUTO-DOCS:END -->
169+
```
170+
163171

164172
What's left to do is to call this function every second. `rclrs` doesn't yet have ROS timers, which run a function at a fixed interval, but it's easy enough to achieve with a thread, a loop, and the sleep function. Change your main function to spawn a separate thread:
165173

@@ -188,7 +196,9 @@ But wait, this doesn't work – there is an error about the thread closure needi
188196
189197
The solution is also the same as above: Shared ownership with `Arc`. Only this time, `Mutex` isn't needed since both the `rclcpp::spin()` and the `republish()` function only require a shared reference:
190198

191-
```rust:examples/minimal_pub_sub/src/first_rclrs_node.rs [40-55]
199+
```
200+
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../examples/minimal_pub_sub/src/first_rclrs_node.rs&lines=40-55) -->
201+
<!-- MARKDOWN-AUTO-DOCS:END -->
192202
```
193203

194204

0 commit comments

Comments
 (0)