Skip to content

Commit f570f19

Browse files
ulfalizercarlescufi
authored andcommitted
doc: genrest: Use , instead of : as the separator in --modules
Using ':' as the separator in --modules breaks module specifications like nrfxlib:nrfxlib:C:/Users/Carles/src/ncs/nrfxlib The ':' in 'C:' gets seen as a separator. Use ',' instead, which is unlikely to appear in paths (at least in --modules). Treat a doubled ',,' as a literal ','. Another option would be ';', but it clashes with how CMake represents lists, which is awkward. Also make quoting of arguments with spaces more robust by passing VERBATIM to add_custom_target(). Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 6a679a9 commit f570f19

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

doc/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ add_custom_target(
194194
kconfig
195195
COMMAND ${CMAKE_COMMAND} -E make_directory ${RST_OUT}/doc/reference/kconfig
196196
COMMAND ${CMAKE_COMMAND} -E env
197-
PYTHONPATH="${ZEPHYR_BASE}/scripts/kconfig${SEP}$ENV{PYTHONPATH}"
197+
PYTHONPATH=${ZEPHYR_BASE}/scripts/kconfig${SEP}$ENV{PYTHONPATH}
198198
ZEPHYR_BASE=${ZEPHYR_BASE}
199199
srctree=${ZEPHYR_BASE}
200200
BOARD_DIR=boards/*/*
@@ -207,13 +207,14 @@ add_custom_target(
207207
KCONFIG_DOC_MODE=1
208208
${PYTHON_EXECUTABLE} scripts/genrest.py ${RST_OUT}/doc/reference/kconfig/
209209
--keep-module-paths
210-
--modules Architecture:arch:${ZEPHYR_BASE}/arch
211-
Driver:drivers:${ZEPHYR_BASE}/drivers
212-
Kernel:kernel:${ZEPHYR_BASE}/kernel
213-
Library:lib:${ZEPHYR_BASE}/lib
214-
Subsystem:subsys:${ZEPHYR_BASE}/subsys
215-
'External Module':modules:${ZEPHYR_BASE}/modules
216-
210+
--modules Architecture,arch,${ZEPHYR_BASE}/arch
211+
Driver,drivers,${ZEPHYR_BASE}/drivers
212+
Kernel,kernel,${ZEPHYR_BASE}/kernel
213+
Library,lib,${ZEPHYR_BASE}/lib
214+
Subsystem,subsys,${ZEPHYR_BASE}/subsys
215+
"External Module,modules,${ZEPHYR_BASE}/modules"
216+
217+
VERBATIM
217218
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
218219
COMMENT "Running genrest.py Kconfig ${RST_OUT}/doc/reference/kconfig/"
219220
)

doc/scripts/genrest.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,21 @@ def init():
106106

107107
modules = []
108108
for module_spec in args.modules:
109-
if module_spec.count(":") == 2:
110-
title, suffix, path_s = module_spec.split(":")
109+
# Split on ',', but keep any ',,' as a literal ','. Temporarily
110+
# represent a literal comma with null.
111+
spec_parts = [part.replace("\0", ",")
112+
for part in module_spec.replace(",,", "\0").split(",")]
113+
114+
if len(spec_parts) == 3:
115+
title, suffix, path_s = spec_parts
111116
desc_path = None
112-
elif module_spec.count(":") == 3:
113-
title, suffix, path_s, desc_path = module_spec.split(":")
117+
elif len(spec_parts) == 4:
118+
title, suffix, path_s, desc_path = spec_parts
114119
else:
115120
sys.exit("error: --modules argument '{}' should have the format "
116-
"<title>:<suffix>:<path> or the format "
117-
"<title>:<suffix>:<path>:<index description filename>"
121+
"<title>,<suffix>,<path> or the format "
122+
"<title>,<suffix>,<path>,<index description filename>. "
123+
"A doubled ',,' in any part is treated as a literal comma."
118124
.format(module_spec))
119125

120126
abspath = pathlib.Path(path_s).resolve()
@@ -160,10 +166,13 @@ def parse_args():
160166
161167
Each MODULE_SPECIFICATION has the form
162168
163-
<title>:<suffix>:<path>[:<index description path>]
169+
<title>,<suffix>,<path>[,<index description path>]
164170
165171
, where <index description path> is optional.
166172
173+
To insert a literal comma into any of the parts, double it,
174+
e.g. 'My title,, with a comma'.
175+
167176
A separate index-<suffix>.rst symbol index page is generated
168177
for each MODULE_SPECIFICATION, with links to all symbols
169178
that are defined inside <path> (possibly more than one level

0 commit comments

Comments
 (0)