diff --git a/doc.lua b/doc.lua index e860182..1f970a1 100644 --- a/doc.lua +++ b/doc.lua @@ -16,8 +16,8 @@ local split_dotted_name = tools.split_dotted_name -- - tags which represent a type, like 'function' (TAG_TYPE) local known_tags = { param = 'M', see = 'M', usage = 'M', ['return'] = 'M', field = 'M', author='M'; - class = 'id', name = 'id', pragma = 'id'; - copyright = 'S', description = 'S', release = 'S'; + class = 'id', name = 'id', pragma = 'id', alias = 'id'; + copyright = 'S', summary = 'S', description = 'S', release = 'S'; module = 'T', script = 'T',['function'] = 'T', table = 'T' } known_tags._alias = {} @@ -108,6 +108,10 @@ function File:finish() if not mod and not this_mod.old_style and item.inferred then --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 + mod = this_mod.mod_name + end -- if that's the mod_name, then we want to only use 'foo' if mod == this_mod.mod_name and this_mod.tags.pragma ~= 'nostrip' then item.name = fname diff --git a/ldoc.lua b/ldoc.lua index 57f5b68..0da49e2 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -125,9 +125,8 @@ local function extract_tags (s) local preamble,tag_items = parse_tags(s) local strip = tools.strip - local summary,description = preamble:match('^(.-)[%.?]%s(.+)') + local summary,description = preamble:match('^(.-[%.?])%s(.+)') if not summary then summary = preamble end - summary = summary .. '.' local tags = {summary=summary and strip(summary),description=description and strip(description)} for _,item in ipairs(tag_items) do local tag,value = item[1],item[2] diff --git a/tests/simple/simple_alias.lua b/tests/simple/simple_alias.lua new file mode 100644 index 0000000..72d17af --- /dev/null +++ b/tests/simple/simple_alias.lua @@ -0,0 +1,16 @@ +------------ +-- A new-style module. +-- Shows how @alias can be used to tell ldoc that a given name +-- is a shorthand for the full module name +-- @alias M + +local simple_alias = {} +local M = simple_alias + +--- return the answer. And complete the description +function M.answer() + return 42 +end + +return simple_alias +