From ff60cbd7aac66a584d73c75c11e96aa4a8ded170 Mon Sep 17 00:00:00 2001 From: Steve Donovan Date: Mon, 27 Jun 2016 11:06:29 +0200 Subject: [PATCH] Modules may return a single _function_ (see tests/funmod.lua) --- ldoc/parse.lua | 9 ++++++--- tests/funmod.lua | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/funmod.lua diff --git a/ldoc/parse.lua b/ldoc/parse.lua index a1ef58d..89e47d3 100644 --- a/ldoc/parse.lua +++ b/ldoc/parse.lua @@ -292,18 +292,21 @@ local function parse_file(fname, lang, package, args) end if item_follows or comment_contains_tags(comment,args) then tags = extract_tags(comment,args) + -- explicitly named @module (which is recommended) if doc.project_level(tags.class) then module_found = tags.name -- might be a module returning a single function! if tags.param or tags['return'] then local parms, ret, summ = tags.param, tags['return'],tags.summary + local name = tags.name tags.param = nil tags['return'] = nil - tags.summary = nil - add_module(tags,tags.name,false) + tags['class'] = nil + tags['name'] = nil + add_module(tags,name,false) tags = { - summary = summ, + summary = '', name = 'returns...', class = 'function', ['return'] = ret, diff --git a/tests/funmod.lua b/tests/funmod.lua new file mode 100644 index 0000000..f9eaef2 --- /dev/null +++ b/tests/funmod.lua @@ -0,0 +1,13 @@ +------- +-- Summing values. +-- Returns a single function. +-- @param a first +-- @param b second +-- @param c third +-- @return sum of parameters +-- @module funmod + +return function(a,b,c) + return a + b + c +end +