From c57c364335e0e71753192cc703410a333acd59a9 Mon Sep 17 00:00:00 2001 From: steve donovan Date: Wed, 15 Jun 2011 16:12:56 +0200 Subject: [PATCH] @local tag to flag a function explicitly as local --- ldoc.lua | 8 +++++--- ldoc/doc.lua | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index abf6714..90d8eed 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -407,7 +407,7 @@ local function parse_file(fname,lang) lang:parse_extra(tags,tok,toks) end end - if tags.class == 'function' and is_local then + if tags.class == 'function' and (is_local or tags['local']) then tags.class = 'lfunction' end if tags.name then @@ -450,7 +450,9 @@ local doc_path = ldoc_dir..'builtin/?.luadoc' -- ldoc -m is expecting a Lua package; this converts this to a file path if args.module then - if args.file:match '^%a+$' and globals[args.file] then + -- first check if we've been given a global Lua lib function + local glob = globals[args.file] + if args.file:match '^%a+$' and glob and type(glob) ~= 'table' then args.file = 'global.'..args.file end local fullpath,mod = tools.lookup_existing_module_or_function (args.file, doc_path) @@ -568,7 +570,7 @@ if args.module then F:dump(args.verbose) else local fun = module_list[1].items.by_name[args.module] - if not fun then quit(args.module.." is not part of this module") end + if not fun then quit(args.module.." is not part of "..args.file) end fun:dump(true) end return diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 10606c1..30c8344 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -20,6 +20,7 @@ local known_tags = { copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S'; module = 'T', script = 'T',['function'] = 'T', lfunction = 'T', table = 'T', section = 'T', type = 'T'; + ['local'] = 'N'; } known_tags._alias = {} known_tags._project_level = { @@ -27,8 +28,9 @@ known_tags._project_level = { script = true } -local TAG_MULTI,TAG_ID,TAG_SINGLE,TAG_TYPE = 'M','id','S','T' -doc.TAG_MULTI,doc.TAG_ID,doc.TAG_SINGLE,doc.TAG_TYPE = TAG_MULTI,TAG_ID,TAG_SINGLE,TAG_TYPE +local TAG_MULTI,TAG_ID,TAG_SINGLE,TAG_TYPE,TAG_FLAG = 'M','id','S','T','N' +doc.TAG_MULTI,doc.TAG_ID,doc.TAG_SINGLE,doc.TAG_TYPE,doc.TAG_FLAG = + TAG_MULTI,TAG_ID,TAG_SINGLE,TAG_TYPE,TAG_FLAG -- add a new tag. function doc.add_tag(tag,type,project_level) @@ -194,6 +196,8 @@ function Item:_init(tags,file,line) end elseif ttype == TAG_SINGLE then self.tags[tag] = value + elseif ttype == TAG_FLAG then + self.tags[tag] = true else self:warning ("unknown tag: '"..tag.."'") end