Skip to content

Commit 58e2057

Browse files
ulfalizerdbkinder
authored andcommitted
genrest: Show symbol help texts on index page
Instead of showing the prompt for symbols on the index page, show their help texts. This makes searching easier. Fall back on the prompt if no help text is available. Also change the code to only show one of the prompts if several are available (happens if a symbol is defined in multiple locations and adds a prompt in more than one of them). It's probably overkill to show them all, and it doesn't come up that often. Suggested by David B. Kinder. Co-authored-by: David B. Kinder <[email protected]> Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 91c8ffa commit 58e2057

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

doc/scripts/genrest.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,38 @@ def sym_table_rst(title, syms):
281281
282282
.. list-table::
283283
:header-rows: 1
284+
:widths: auto
284285
285286
* - Symbol name
286-
- Prompt
287+
- Help/prompt
287288
""".format(title, len(title)*"*")
288289

289290
for sym in sorted(syms, key=attrgetter("name")):
290291
rst += """\
291292
* - :option:`CONFIG_{}`
292293
- {}
293-
""".format(sym.name,
294-
" / ".join(node.prompt[0] for node in sym.nodes if node.prompt))
294+
""".format(sym.name, sym_index_desc(sym))
295295

296296
return rst
297297

298298

299+
def sym_index_desc(sym):
300+
# Returns the description used for 'sym' on the index page
301+
302+
# Use the first help text, if available
303+
for node in sym.nodes:
304+
if node.help is not None:
305+
return node.help.replace("\n", "\n ")
306+
307+
# If there's no help, use the first prompt string
308+
for node in sym.nodes:
309+
if node.prompt:
310+
return node.prompt[0]
311+
312+
# No help text or prompt
313+
return ""
314+
315+
299316
def index_header(title, link, desc_path):
300317
# Returns the RST for the beginning of a symbol index page.
301318
#

0 commit comments

Comments
 (0)