From ee912671eb113a9741965ea887cc199df6568426 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 24 Nov 2019 23:04:13 -0500 Subject: [PATCH] doc: Add a standard `@propbeautiful` tag. This allows to state that this variable has a equivalent beautiful variable named using the usual conventions. It will generate all the boilerplate magically and also takes optional fallback variable names. --- docs/config.ld | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/config.ld b/docs/config.ld index 692d754d..5e855040 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -306,6 +306,37 @@ add_custom_tag { } } +-- For all properties which have a standard `@beautiful` variable for them +-- @propbeautiful fallback1 fallback2 fallback3 fallback4 +add_custom_tag { + name = "propbeautiful", + title = "Consumed theme variables", + params = { + { name = "fallback1" }, + { name = "fallback2" }, + { name = "fallback3" }, + { name = "fallback4" }, + }, + table = { + "Variable", "Usage" + }, + format = function(self, p, item, md) + local modname = item.module.name:gmatch("[^.]+$")() + local last = "beautiful."..(modname.."_"..item.name):gsub("[.]", "_") + local ret = ""..md("`"..last.."`").."Fallback when "..md("`"..item.name.."`").. + " isn't set." + + for _, fallback in ipairs({p.fallback1, p.fallback2, p.fallback3, p.fallback4 }) do + ret = ret .. "".. + ""..md("`"..fallback.value.."`").."Fallback when "..md("`"..last.."`").. + " isn't set." + last = fallback.value + end + + return ret + end +} + -- Define the base class where a method/property is implemented. -- @baseclass my_module.my_submodule.my_baseclass add_custom_tag { @@ -412,7 +443,8 @@ local named_args = { } local delimiter_for_tag = { - usebeautiful = { "table class='widget_list' border=1", "table", "tr", "tr", {"Theme variable", "Usage"}} + usebeautiful = { "table class='widget_list' border=1", "table", "tr", "tr", {"Theme variable", "Usage"}}, + propbeautiful = { "table class='widget_list' border=1", "table", "tr", "tr", {"Theme variable", "Usage"}}, } -- Use the first word of the subtag content to map it to its tag.