no longer an error for @function to have modifiers (#45), although we're not yet passing it through. New @static tag for class methods

This commit is contained in:
steve donovan 2013-03-07 13:39:41 +02:00
parent 7f1d50b778
commit d7ee2d806f
2 changed files with 21 additions and 11 deletions

View File

@ -25,7 +25,7 @@ local known_tags = {
class = 'id', name = 'id', pragma = 'id', alias = 'id', within = 'id', class = 'id', name = 'id', pragma = 'id', alias = 'id', within = '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', raise = 'S', fixme = 'S', todo = 'S', warning = 'S', raise = 'S',
['local'] = 'N', export = 'N', private = 'N', constructor = 'N'; ['local'] = 'N', export = 'N', private = 'N', constructor = 'N', static = 'N';
-- project-level -- project-level
module = 'T', script = 'T', example = 'T', topic = 'T', submodule='T', module = 'T', script = 'T', example = 'T', topic = 'T', submodule='T',
-- module-level -- module-level
@ -302,7 +302,8 @@ function File:finish()
if doc.class_tag(stype) then if doc.class_tag(stype) then
if not item.name:match '[:%.]' then -- not qualified if not item.name:match '[:%.]' then -- not qualified
local class = this_section.name local class = this_section.name
item.name = class..(not item.tags.constructor and ':' or '.')..item.name local static = item.tags.constructor or item.tags.static
item.name = class..(not static and ':' or '.')..item.name
end end
if stype == 'factory' then if stype == 'factory' then
if item.tags.private then to_be_removed = true if item.tags.private then to_be_removed = true
@ -375,7 +376,6 @@ function Item:_init(tags,file,line)
for tag in iter(tags) do for tag in iter(tags) do
self:set_tag(tag,tags[tag]) self:set_tag(tag,tags[tag])
end end
--for tag,value in pairs(tags) do print('tag',tag,value) end
end end
function Item:add_to_description (rest) function Item:add_to_description (rest)
@ -399,15 +399,16 @@ function Item:set_tag (tag,value)
end end
self.tags[tag] = value self.tags[tag] = value
elseif ttype == TAG_ID then elseif ttype == TAG_ID then
--print('id',tag,value) if type(value) == 'table' then
if type(value) ~= 'string' then if value.append then -- it was a List!
-- such tags are _not_ multiple, e.g. name -- such tags are _not_ multiple, e.g. name
self:error("'"..tag.."' cannot have multiple values") self:error("'"..tag.."' cannot have multiple values")
else end
local id, rest = tools.extract_identifier(value) value = value[1]
self.tags[tag] = id
self:add_to_description(rest)
end end
local id, rest = tools.extract_identifier(value)
self.tags[tag] = id
self:add_to_description(rest)
elseif ttype == TAG_SINGLE then elseif ttype == TAG_SINGLE then
self.tags[tag] = value self.tags[tag] = value
elseif ttype == TAG_FLAG then elseif ttype == TAG_FLAG then

View File

@ -24,11 +24,20 @@ usage.Vector = {}
function Vector.new (t) function Vector.new (t)
end end
-- note that @function may have modifiers. Currently
-- we aren't doing anything with them, but LDoc no longer
-- complains (issue #45). Note also that one needs
-- explicit @param tags with explicit @function; 'static'
-- methods must have a @constructor or a @static tag.
---------- ----------
-- Create a vector from a string. -- Create a vector from a string.
-- @usage -- @usage
-- v = Vector.parse '[1,2,3]' -- v = Vector.parse '[1,2,3]'
-- assert (v == Vector.new {1,2,3}) -- assert (v == Vector.new {1,2,3})
-- @function[kind=ctor] parse
-- @static
-- @param s
function Vector.parse (s) function Vector.parse (s)
end end