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',
copyright = 'S', summary = 'S', description = 'S', release = 'S', license = '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
module = 'T', script = 'T', example = 'T', topic = 'T', submodule='T',
-- module-level
@ -302,7 +302,8 @@ function File:finish()
if doc.class_tag(stype) then
if not item.name:match '[:%.]' then -- not qualified
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
if stype == 'factory' then
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
self:set_tag(tag,tags[tag])
end
--for tag,value in pairs(tags) do print('tag',tag,value) end
end
function Item:add_to_description (rest)
@ -399,15 +399,16 @@ function Item:set_tag (tag,value)
end
self.tags[tag] = value
elseif ttype == TAG_ID then
--print('id',tag,value)
if type(value) ~= 'string' then
-- such tags are _not_ multiple, e.g. name
self:error("'"..tag.."' cannot have multiple values")
else
local id, rest = tools.extract_identifier(value)
self.tags[tag] = id
self:add_to_description(rest)
if type(value) == 'table' then
if value.append then -- it was a List!
-- such tags are _not_ multiple, e.g. name
self:error("'"..tag.."' cannot have multiple values")
end
value = value[1]
end
local id, rest = tools.extract_identifier(value)
self.tags[tag] = id
self:add_to_description(rest)
elseif ttype == TAG_SINGLE then
self.tags[tag] = value
elseif ttype == TAG_FLAG then

View File

@ -24,11 +24,20 @@ usage.Vector = {}
function Vector.new (t)
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.
-- @usage
-- v = Vector.parse '[1,2,3]'
-- assert (v == Vector.new {1,2,3})
-- @function[kind=ctor] parse
-- @static
-- @param s
function Vector.parse (s)
end