20 | 20 |
-- - 'N' tags which have no associated value, like 'local` (TAG_FLAG)
|
21 | 21 |
-- - 'T' tags which represent a type, like 'function' (TAG_TYPE)
|
22 | 22 |
local known_tags = {
|
23 | |
param = 'M', see = 'M', usage = 'ML', ['return'] = 'M', field = 'M', author='M',set='M';
|
|
23 |
param = 'M', see = 'M', comment = 'M', usage = 'ML', ['return'] = 'M', field = 'M', author='M',set='M';
|
24 | 24 |
class = 'id', name = 'id', pragma = 'id', alias = 'id', within = 'id',
|
25 | 25 |
copyright = 'S', summary = 'S', description = 'S', release = 'S', license = 'S',
|
26 | 26 |
fixme = 'S', todo = 'S', warning = 'S', raise = 'S', charset = 'S',
|
|
129 | 129 |
|
130 | 130 |
function doc.expand_annotation_item (tags, last_item)
|
131 | 131 |
if tags.summary ~= '' then return false end
|
|
132 |
local item_name = last_item and last_item.tags.name or '?'
|
132 | 133 |
for tag, value in pairs(tags) do
|
133 | 134 |
if known_tags._annotation_tags[tag] then
|
134 | 135 |
tags:add('class','annotation')
|
135 | 136 |
tags:add('summary',value)
|
136 | |
local item_name = last_item and last_item.tags.name or '?'
|
137 | 137 |
tags:add('name',item_name..'-'..tag..acount)
|
138 | 138 |
acount = acount + 1
|
139 | 139 |
return true
|
|
434 | 434 |
|
435 | 435 |
if ttype == TAG_MULTI or ttype == TAG_MULTI_LINE then -- value is always a List!
|
436 | 436 |
local ovalue = self.tags[tag]
|
437 | |
if is_list(ovalue) then
|
438 | |
ovalue:append(value)
|
|
437 |
if ovalue then -- already defined, must be a list
|
|
438 |
--print(tag,ovalue,value)
|
|
439 |
if is_list(value) then
|
|
440 |
ovalue:extend(value)
|
|
441 |
else
|
|
442 |
ovalue:append(value)
|
|
443 |
end
|
439 | 444 |
value = ovalue
|
440 | 445 |
end
|
|
446 |
-- these multiple values are always represented as lists
|
441 | 447 |
if not is_list(value) then
|
442 | 448 |
value = List{value}
|
443 | 449 |
end
|
|
834 | 840 |
return r.type, r.ctypes
|
835 | 841 |
end
|
836 | 842 |
|
|
843 |
local struct_return_type = '*'
|
|
844 |
|
837 | 845 |
function Item:build_return_groups()
|
838 | 846 |
local modifiers = self.modifiers
|
839 | 847 |
local retmod = modifiers['return']
|
|
848 | 856 |
groups:append(group)
|
849 | 857 |
lastg = g
|
850 | 858 |
end
|
|
859 |
--require 'pl.pretty'.dump(ret)
|
851 | 860 |
group:append({text=ret, type = mods.type or '',mods = mods})
|
852 | 861 |
end
|
853 | 862 |
-- order by groups to force error groups to the end
|
854 | 863 |
table.sort(groups,function(g1,g2) return g1.g < g2.g end)
|
855 | 864 |
self.retgroups = groups
|
|
865 |
--require 'pl.pretty'.dump(groups)
|
856 | 866 |
-- cool, now see if there are any treturns that have tfields to associate with
|
857 | 867 |
local fields = self.tags.field
|
858 | 868 |
if fields then
|
|
860 | 870 |
for i,f in ipairs(fields) do
|
861 | 871 |
local name, comment = self:split_param(f)
|
862 | 872 |
fields[i] = name
|
863 | |
fcomments[i] = coment
|
|
873 |
fcomments[i] = comment
|
864 | 874 |
end
|
865 | 875 |
local fmods = modifiers.field
|
866 | 876 |
for group in groups:iter() do for r in group:iter() do
|
867 | |
if r.mods and r.mods.type == '*' then
|
868 | |
local ctypes = List()
|
869 | |
for i,f in ipairs(fields) do
|
|
877 |
if r.mods and r.mods.type then
|
|
878 |
local ctypes, T = List(), r.mods.type
|
|
879 |
for i,f in ipairs(fields) do if fmods[i][T] then
|
870 | 880 |
ctypes:append {name=f,type=fmods[i].type,comment=fcomments[i]}
|
871 | |
end
|
|
881 |
end end
|
872 | 882 |
r.ctypes = ctypes
|
|
883 |
--require 'pl.pretty'.dump(ctypes)
|
873 | 884 |
end
|
874 | 885 |
end end
|
875 | 886 |
end
|
876 | 887 |
end
|
|
888 |
|
|
889 |
local ecount = 0
|
877 | 890 |
|
878 | 891 |
-- this alias macro implements @error.
|
879 | 892 |
-- Alias macros need to return the same results as Item:check_tags...
|
880 | 893 |
function doc.error_macro(tags,value,modifiers)
|
|
894 |
local merge_groups = doc.ldoc.merge_error_groups
|
881 | 895 |
local g = '2' -- our default group id
|
882 | 896 |
-- Were we given an explicit group modifier?
|
883 | 897 |
local key = integer_keys(modifiers)
|
|
887 | 901 |
local l = tags:get 'return'
|
888 | 902 |
if l then -- there were returns already......
|
889 | 903 |
-- maximum group of _existing_ error return
|
890 | |
local grp, text = 0, List()
|
|
904 |
local grp, lastr = 0
|
891 | 905 |
for r in l:iter() do if type(r) == 'table' then
|
892 | |
grp = math.max(grp,r.modifiers._err or 0)
|
893 | |
text:append(r[1])
|
|
906 |
local rg = r.modifiers._err
|
|
907 |
if rg then
|
|
908 |
lastr = r
|
|
909 |
grp = math.max(grp,rg)
|
|
910 |
end
|
894 | 911 |
end end
|
895 | 912 |
if grp > 0 then -- cool, create new group
|
896 | |
g = tostring(grp+1)
|
897 | |
text:append(value)
|
|
913 |
if not merge_groups then
|
|
914 |
g = tostring(grp+1)
|
|
915 |
else
|
|
916 |
local mods, text, T = lastr.modifiers
|
|
917 |
local new = function(text)
|
|
918 |
return mods._collected..' '..text,{type='string',[T]=true}
|
|
919 |
end
|
|
920 |
if not mods._collected then
|
|
921 |
text = lastr[1]
|
|
922 |
lastr[1] = merge_groups
|
|
923 |
T = '@'..ecount
|
|
924 |
mods.type = T
|
|
925 |
mods._collected = 1
|
|
926 |
ecount = ecount + 1
|
|
927 |
tags:add('field',new(text))
|
|
928 |
else
|
|
929 |
T = mods.type
|
|
930 |
end
|
|
931 |
mods._collected = mods._collected + 1
|
|
932 |
return 'field',new(value)
|
|
933 |
end
|
898 | 934 |
end
|
899 | 935 |
end
|
900 | 936 |
end
|