diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 3f19a85..68a1871 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -21,7 +21,7 @@ local TAG_MULTI,TAG_ID,TAG_SINGLE,TAG_TYPE,TAG_FLAG,TAG_MULTI_LINE = 'M','id','S -- - 'N' tags which have no associated value, like 'local` (TAG_FLAG) -- - 'T' tags which represent a type, like 'function' (TAG_TYPE) local known_tags = { - param = 'M', see = 'M', usage = 'ML', ['return'] = 'M', field = 'M', author='M'; + param = 'M', see = 'M', usage = 'ML', ['return'] = 'M', field = 'M', author='M',set='M'; class = 'id', name = 'id', pragma = 'id', alias = 'id', within = 'id', copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S', fixme = 'S', todo = 'S', warning = 'S', raise = 'S', charset = 'S', @@ -626,6 +626,9 @@ function Item:finish() local names = List() self.subparams = {} for i,name in ipairs(original_names) do + if type(name) ~= 'string' then + self:error("declared table cannot have array entries") + end local pname,field = split_iden(name) if field then if not fields then diff --git a/ldoc/html.lua b/ldoc/html.lua index 418ccf7..efb6f57 100644 --- a/ldoc/html.lua +++ b/ldoc/html.lua @@ -18,6 +18,7 @@ local utils = require 'pl.utils' local path = require 'pl.path' local stringx = require 'pl.stringx' local template = require 'pl.template' +local tablex = require 'pl.tablex' local tools = require 'ldoc.tools' local markup = require 'ldoc.markup' local prettify = require 'ldoc.prettify' @@ -55,6 +56,19 @@ local escape_table = { ["'"] = "'", ["\""] = """, ["<"] = "<", [">" function html.generate_output(ldoc, args, project) local check_directory, check_file, writefile = tools.check_directory, tools.check_file, tools.writefile + local original_ldoc + + local function save_ldoc () + if not original_ldoc then + original_ldoc = tablex.copy(ldoc) + end + end + + local function restore_ldoc () + if original_ldoc then + ldoc = original_ldoc + end + end function ldoc.escape(str) return (str:gsub("['&<>\"]", escape_table)) @@ -236,6 +250,14 @@ function html.generate_output(ldoc, args, project) for m in modules() do ldoc.module = m ldoc.body = m.body + if m.tags.set then + save_ldoc() + for s in m.tags.set:iter() do + local var,val = s:match('([^=]+)=(.+)') + print('setting',var,val) + ldoc[var] = val + end + end set_charset(ldoc) m.info = get_module_info(m) if ldoc.body and m.postprocess then @@ -251,6 +273,7 @@ function html.generate_output(ldoc, args, project) out = cleanup_whitespaces(out) writefile(args.dir..lkind..'/'..m.name..args.ext,out) end + restore_ldoc() end end if not args.quiet then print('output written to '..tools.abspath(args.dir)) end