diff --git a/ldoc.lua b/ldoc.lua index 2a8b9e3..a05a193 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -168,11 +168,13 @@ end local quit = utils.quit --- parses a Lua file, looking for ldoc comments. These are like LuaDoc comments; --- they start with multiple '-'. If they don't define a name tag, then by default +-- parses a Lua or C file, looking for ldoc comments. These are like LuaDoc comments; +-- they start with multiple '-'. (Block commments are allowed) +-- If they don't define a name tag, then by default -- it is assumed that a function definition follows. If it is the first comment -- encountered, then ldoc looks for a call to module() to find the name of the --- module. +-- module if there isn't an explicit module name specified. + local function parse_file(fname,lang) local line,f = 1 local F = File(fname) diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 2867aaa..13d637e 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -134,7 +134,8 @@ function File:finish() --item:warning(item.name .. ' is declared in global scope') end -- the function may be qualified with a module alias... - if this_mod.tags.alias and mod == this_mod.tags.alias then + local alias = this_mod.tags.alias + if (alias and mod == alias) or mod == 'M' or mod == '_M' then mod = this_mod.mod_name end -- if that's the mod_name, then we want to only use 'foo' diff --git a/ldoc/tools.lua b/ldoc/tools.lua index 546bb2f..bbb491d 100644 --- a/ldoc/tools.lua +++ b/ldoc/tools.lua @@ -188,7 +188,6 @@ end function M.this_module_name (basename,fname) local ext if basename == '' then - --quit("module(...) needs package basename") return M.name_of(fname) end basename = path.abspath(basename) @@ -198,7 +197,7 @@ function M.this_module_name (basename,fname) local lpath,cnt = fname:gsub('^'..utils.escape(basename),'') if cnt ~= 1 then quit("module(...) name deduction failed: base "..basename.." "..fname) end lpath = lpath:gsub(path.sep,'.') - return M.name_of(lpath) + return M.name_of(lpath):gsub('%.init$','') end function M.find_existing_module (name, searchfn)