Skip to content

Commit 5de530a

Browse files
fujitatomoyamergify[bot]
authored andcommitted
check and sort the codespell dictionaries via make target. (#5629)
* check and sort the codespell dictionaries via make target. Signed-off-by: Tomoya Fujita <[email protected]> * add sort-dictionaries make target and github action. Signed-off-by: Tomoya Fujita <[email protected]> * address review comment. Signed-off-by: Tomoya Fujita <[email protected]> --------- Signed-off-by: Tomoya Fujita <[email protected]> (cherry picked from commit dc5e7ba) # Conflicts: # Makefile
1 parent 5c318a6 commit 5de530a

File tree

5 files changed

+58
-7
lines changed

5 files changed

+58
-7
lines changed

.github/workflows/dictionaries.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Check Dictionaries
2+
3+
on:
4+
push:
5+
paths:
6+
- 'codespell_dictionary.txt'
7+
- 'codespell_whitelist.txt'
8+
pull_request:
9+
paths:
10+
- 'codespell_dictionary.txt'
11+
- 'codespell_whitelist.txt'
12+
13+
jobs:
14+
check-dictionaries:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Run make check-dictionaries
19+
run: |
20+
make check-dictionaries || (echo "check-dictionaries failed, run: make sort-dictionaries")

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ endif
1010
BUILD = $(PYTHON) -m sphinx
1111
OPTS =-c . -W # Treat warnings as errors
1212

13+
DICTIONARIES := codespell_dictionary.txt codespell_whitelist.txt
14+
1315
help:
1416
@$(BUILD) -M help "$(SOURCE)" "$(OUT)" $(OPTS)
1517
@echo " multiversion to build documentation for all branches"
@@ -31,9 +33,33 @@ test:
3133
spellcheck:
3234
git ls-files '*.md' '*.rst' | xargs codespell --config codespell.cfg
3335

36+
check-dictionaries:
37+
@echo "Checking dictionaries..."
38+
@for dict in $(DICTIONARIES); do \
39+
echo "Checking $$dict..."; \
40+
if grep -E -n "^\s*$$|\s$$|^\s" $$dict; then \
41+
echo "Dictionary $$dict contains empty lines or leading/trailing spaces, triming..."; \
42+
sed -E -i.bak -e 's/^[[:space:]]+//; s/[[:space:]]+$$//; /^$$/d' $$dict && rm $$dict.bak; \
43+
fi; \
44+
done
45+
46+
sort-dictionaries:
47+
@echo "Sorting dictionaries..."
48+
@for dict in $(DICTIONARIES); do \
49+
echo "Sorting $$dict..."; \
50+
if ! LC_ALL=C sort -f -b -c $$dict; then \
51+
echo "Dictionary $$dict is not sorted, sorting..."; \
52+
LC_ALL=C sort -f -b -o $$dict $$dict; \
53+
fi; \
54+
done
55+
3456
linkcheck:
3557
$(BUILD) -b linkcheck $(OPTS) $(SOURCE) $(LINKCHECKDIR)
3658
@echo
3759
@echo "Check finished. Report is in $(LINKCHECKDIR)."
3860

61+
<<<<<<< HEAD
3962
.PHONY: help Makefile multiversion test linkcheck
63+
=======
64+
.PHONY: help Makefile multiversion test test-unit linkcheck lint spellcheck check-dictionaries sort-dictionaries
65+
>>>>>>> dc5e7ba (check and sort the codespell dictionaries via make target. (#5629))

codespell_dictionary.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
amnet->ament
21
amemt->ament
32
amentt->ament
3+
amnet->ament
4+
caktin->catkin
45
catikn->catkin
56
catin->catkin
6-
caktin->catkin
7-
colcno->colcon
87
colcn->colcon
8+
colcno->colcon
99
colcom->colcon
1010
colconb->colcon
1111
colconm->colcon

codespell_whitelist.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
empy
2-
ws
3-
lets
42
jupyter
3+
lets
4+
ws

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ To do this, add it to the `codespell_whitelist <https://github.com/ros2/ros2_doc
186186
.. code-block:: text
187187
188188
empy
189-
ws
190-
lets
191189
jupyter
190+
lets
191+
ws
192192
193193
To include custom corrections that ``codespell`` should apply, you can add them to the `codespell_dictionary <https://github.com/ros2/ros2_documentation/blob/{REPOS_FILE_BRANCH}/codespell_dictionary.txt>`_ file as follows:
194194

@@ -199,6 +199,11 @@ To include custom corrections that ``codespell`` should apply, you can add them
199199
rosabg->rosbag
200200
rosdistroy->rosdistro
201201
202+
To check the dictionaries, you can run the ``make check-dictionaries`` command.
203+
This will check the blank lines and leading/trailing spaces in the dictionaries.
204+
If it complains about the dictionaries, you can run the ``make sort-dictionaries`` command.
205+
This command will automatically modify the dictionaries if any issues are found.
206+
202207
Migrating Pages from the ROS Wiki
203208
---------------------------------
204209

0 commit comments

Comments
 (0)