From 8d22dc7b2c9174f495bcbe45d96b26afeabde98a Mon Sep 17 00:00:00 2001 From: steve donovan Date: Fri, 26 Aug 2011 15:34:42 +0200 Subject: [PATCH] new flag --tags and some more builtin tags. So --tag fixme will show all occurances of @fixme in a project --- ldoc.lua | 8 ++++++++ ldoc/doc.lua | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ldoc.lua b/ldoc.lua index c201f76..410cb97 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -32,6 +32,7 @@ ldoc, a documentation generator for Lua, vs 0.6 -c,--config (default config.ld) configuration name --dump debug output dump --filter (default none) filter output as Lua data (e.g pl.pretty.dump) + --tags (default none) show all references to a given tag (string) source file or directory containing source ]] @@ -409,6 +410,13 @@ if args.dump then end os.exit() end +if args.tags then + local taglist = {[args.tags] = true} + for mod in module_list:iter() do + mod:dump_tags(taglist) + end + os.exit() +end -- ldoc --filter mod.name will load the module `mod` and pass the object graph -- to the function `name`. As a special case --filter dump will use pl.pretty.dump. diff --git a/ldoc/doc.lua b/ldoc/doc.lua index 1511aec..0299ebc 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -17,7 +17,8 @@ local split_dotted_name = tools.split_dotted_name local known_tags = { param = 'M', see = 'M', usage = 'M', ['return'] = 'M', field = 'M', author='M'; class = 'id', name = 'id', pragma = 'id', alias = 'id'; - copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S'; + copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S', + fixme = 'S', todo = 'S', warning = 'S'; module = 'T', script = 'T', example = 'T', topic = 'T', -- project-level ['function'] = 'T', lfunction = 'T', table = 'T', section = 'T', type = 'T'; -- module-level ['local'] = 'N'; @@ -408,6 +409,21 @@ function Module:mask_locals () self.kinds['Local Functions'] = nil end +function Item:dump_tags (taglist) + for tag, value in pairs(self.tags) do + if not taglist or taglist[tag] then + Item.warning(self,self.name..' '..tag..' '..tostring(value)) + end + end +end + +function Module:dump_tags (taglist) + Item.dump_tags(self,taglist) + for item in self.items:iter() do + item:dump_tags(taglist) + end +end + --------- dumping out modules and items ------------- function Module:dump(verbose)