support for annotations: an item containing one of fixme, todo or warning can appear anywhere in code

This commit is contained in:
steve donovan 2011-09-17 19:13:47 +02:00
parent c370529976
commit f5c11dcdf5
3 changed files with 28 additions and 2 deletions

View File

@ -58,6 +58,7 @@ ModuleMap:add_kind('function','Functions','Parameters')
ModuleMap:add_kind('table','Tables','Fields')
ModuleMap:add_kind('field','Fields')
ModuleMap:add_kind('lfunction','Local Functions','Parameters')
ModuleMap:add_kind('annotation','Annotations')
class.ProjectMap(KindMap)

View File

@ -20,7 +20,8 @@ local known_tags = {
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
['function'] = 'T', lfunction = 'T', table = 'T', section = 'T', type = 'T',
annotation = 'T'; -- module-level
['local'] = 'N';
}
known_tags._alias = {}
@ -30,6 +31,9 @@ known_tags._project_level = {
example = true,
topic = true
}
known_tags._annotation_tags = {
fixme = true, todo = true, warning = true
}
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 =
@ -63,6 +67,23 @@ function doc.section_tag (tag)
return tag == 'section' or tag == 'type'
end
-- is it an annotation tag, like fixme or todo?
function doc.annotation_tag (tag)
return known_tags._annotation_tags[tag]
end
local acount = 1
function doc.expand_annotation_item (tags)
local tag, value = next(tags)
if doc.annotation_tag(tag) then
tags.class = 'annotation'
tags.summary = value
tags.name = tag..acount
acount = acount+1
end
end
-- we process each file, resulting in a File object, which has a list of Item objects.
-- Items can be modules, scripts ('project level') or functions, tables, etc.
-- (In the code 'module' refers to any project level tag.)
@ -403,11 +424,12 @@ function Module:resolve_references(modules)
end
end
-- suppress the display of local functions.
-- suppress the display of local functions and annotations.
-- This is just a placeholder hack until we have a more general scheme
-- for indicating 'private' content of a module.
function Module:mask_locals ()
self.kinds['Local Functions'] = nil
self.kinds['Annotations'] = nil
end
function Item:dump_tags (taglist)

View File

@ -165,6 +165,9 @@ local function parse_file(fname,lang, package)
if doc.project_level(tags.class) then
module_found = tags.name
end
doc.expand_annotation_item(tags)
-- if the item has an explicit name or defined meaning
-- then don't continue to do any code analysis!
if tags.name then
item_follows, is_local = false, false
end