From 55bbeed4f44dbe622dbe48eb0842474b81507058 Mon Sep 17 00:00:00 2001 From: steve donovan Date: Mon, 28 Jan 2013 11:23:31 +0200 Subject: [PATCH] added module merging - see tests/merge directory (--merge flag) --- ldoc.lua | 4 +++- ldoc/doc.lua | 8 ++++++++ ldoc/parse.lua | 2 ++ tests/merge/config.ld | 2 ++ tests/merge/merge1.lua | 7 +++++++ tests/merge/merge2.lua | 19 +++++++++++++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/merge/config.ld create mode 100644 tests/merge/merge1.lua create mode 100644 tests/merge/merge2.lua diff --git a/ldoc.lua b/ldoc.lua index 96f636d..3d9489a 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -55,6 +55,7 @@ ldoc, a documentation generator for Lua, vs 1.3.1 -D,--define (default none) set a flag to be used in config.ld -C,--colon use colon style -B,--boilerplate ignore first comment in source files + -M,--merge allow module merging --dump debug output dump --filter (default none) filter output as Lua data (e.g pl.pretty.dump) --tags (default none) show all references to given tags, comma-separated @@ -181,7 +182,7 @@ local ldoc_contents = { 'alias','add_language_extension','new_type','add_section', 'tparam_alias', 'file','project','title','package','format','output','dir','ext', 'topics', 'one','style','template','description','examples', - 'readme','all','manual_url', 'ignore', 'colon','boilerplate', + 'readme','all','manual_url', 'ignore', 'colon','boilerplate','merge', 'no_return_or_parms','no_summary','full_description','backtick_references', 'custom_see_handler', } ldoc_contents = tablex.makeset(ldoc_contents) @@ -348,6 +349,7 @@ local process_file_list = tools.process_file_list setup_package_base() override 'colon' +override 'merge' if type(args.file) == 'table' then -- this can only be set from config file so we can assume it's already read diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 4e56478..e89093a 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -215,6 +215,14 @@ function File:finish() if item.type == 'module' then -- if name is 'package.mod', then mod_name is 'mod' package,mname = split_dotted_name(this_mod.name) + if self.args.merge then + local mod,mf = find_module_in_files(item.name) + if mod then + print('found master module',mf) + this_mod = mod + submodule = true + end + end elseif item.type == 'submodule' then local mf submodule = true diff --git a/ldoc/parse.lua b/ldoc/parse.lua index c962bce..7e4a2dd 100644 --- a/ldoc/parse.lua +++ b/ldoc/parse.lua @@ -150,6 +150,8 @@ local function parse_file(fname, lang, package, args) local module_found, first_comment = false,true local current_item, module_item + F.args = args + F.base = package local tok,f = lang.lexer(fname) diff --git a/tests/merge/config.ld b/tests/merge/config.ld new file mode 100644 index 0000000..bf9e5ab --- /dev/null +++ b/tests/merge/config.ld @@ -0,0 +1,2 @@ +merge=true +file={'merge1.lua','merge2.lua'} diff --git a/tests/merge/merge1.lua b/tests/merge/merge1.lua new file mode 100644 index 0000000..7e07e15 --- /dev/null +++ b/tests/merge/merge1.lua @@ -0,0 +1,7 @@ +---- +-- main module +-- @module merge + +---- first fun +function one() +end diff --git a/tests/merge/merge2.lua b/tests/merge/merge2.lua new file mode 100644 index 0000000..c0acfb3 --- /dev/null +++ b/tests/merge/merge2.lua @@ -0,0 +1,19 @@ +---- +-- submodule +-- @module merge + +---- second fun +-- @param x +function two(x) +end + +--- extra stuff +-- @section extra + +--- third fun +function three () +end + +--- fourth fun +function four () +end