From 3ff8a8da55a454dc70e835880f6af2d95f227d2b Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Wed, 31 Mar 2021 22:26:49 +0200 Subject: [PATCH] schema: Include table descriptions in generated MD --- schema.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/schema.lua b/schema.lua index fdb610e..d1b691b 100644 --- a/schema.lua +++ b/schema.lua @@ -72,11 +72,23 @@ end function generate_markdown(self) -- TODO address redundancies + local function description(lines) + local description = self.description + if description then + if type(description) ~= "table" then + table.insert(lines, description) + else + modlib.table.append(lines, description) + end + end + end local typ = self.type self.title = self.title or field_name_to_title(self._md_name) self._md_level = self._md_level or 1 if typ == "table" then local settings = {} + description(settings) + -- TODO generate Markdown for key/value-checks local function setting(key, value_scheme) value_scheme._md_name = key value_scheme.title = value_scheme.title or self.title .. " " .. field_name_to_title(key) @@ -103,14 +115,6 @@ function generate_markdown(self) local function line(text) table.insert(lines, "* " .. text) end - local description = self.description - if description then - if type(description) ~= "table" then - table.insert(lines, description) - else - modlib.table.append(lines, description) - end - end table.insert(lines, "") line("Type: " .. self.type) if self.default ~= nil then