schema: Include table descriptions in generated MD

This commit is contained in:
Lars Mueller 2021-03-31 22:26:49 +02:00
parent 69067579e5
commit 3ff8a8da55

@ -72,11 +72,23 @@ end
function generate_markdown(self) function generate_markdown(self)
-- TODO address redundancies -- 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 local typ = self.type
self.title = self.title or field_name_to_title(self._md_name) self.title = self.title or field_name_to_title(self._md_name)
self._md_level = self._md_level or 1 self._md_level = self._md_level or 1
if typ == "table" then if typ == "table" then
local settings = {} local settings = {}
description(settings)
-- TODO generate Markdown for key/value-checks
local function setting(key, value_scheme) local function setting(key, value_scheme)
value_scheme._md_name = key value_scheme._md_name = key
value_scheme.title = value_scheme.title or self.title .. " " .. field_name_to_title(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) local function line(text)
table.insert(lines, "* " .. text) table.insert(lines, "* " .. text)
end 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, "") table.insert(lines, "")
line("Type: " .. self.type) line("Type: " .. self.type)
if self.default ~= nil then if self.default ~= nil then