Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions doc/scripts/genrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,32 @@ def defaults_rst(sc):
# Returns RST that lists the 'default' properties of 'sc' (symbol or
# choice)

if not sc.defaults:
if isinstance(sc, kconfiglib.Symbol) and sc.choice:
# 'default's on choice symbols have no effect (and generate a warning).
# The implicit value hint below would be misleading as well.
return ""

rst = "Defaults\n" \
"========\n\n"

for value, cond in sc.defaults:
default_str = kconfiglib.expr_str(value)
if cond is not sc.kconfig.y:
default_str += " if " + kconfiglib.expr_str(cond)
rst += "- {}\n".format(default_str)
if sc.defaults:
for value, cond in sc.defaults:
rst += "- " + kconfiglib.expr_str(value)
if cond is not sc.kconfig.y:
rst += " if " + kconfiglib.expr_str(cond)
rst += "\n"

else:
rst += "No defaults. Implicitly defaults to "

if isinstance(sc, kconfiglib.Choice):
rst += "the first (visible) choice option.\n"
elif sc.orig_type in (kconfiglib.BOOL, kconfiglib.TRISTATE):
rst += "``n``.\n"
else:
# This is accurate even for int/hex symbols, though an active
# 'range' might clamp the value (which is then treated as zero)
rst += "the empty string.\n"

return rst + "\n"

Expand Down