diff --git a/doc/scripts/genrest.py b/doc/scripts/genrest.py index 2d6473cfef0e3..d8a2e78ae5f36 100644 --- a/doc/scripts/genrest.py +++ b/doc/scripts/genrest.py @@ -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"