Skip to content

Commit

Permalink
added module merging - see tests/merge directory (--merge flag)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedonovan committed Jan 28, 2013
1 parent 10b5819 commit 55bbeed
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ldoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions ldoc/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ldoc/parse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/merge/config.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
merge=true
file={'merge1.lua','merge2.lua'}
7 changes: 7 additions & 0 deletions tests/merge/merge1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
----
-- main module
-- @module merge

---- first fun
function one()
end
19 changes: 19 additions & 0 deletions tests/merge/merge2.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 55bbeed

Please sign in to comment.