22 | 22 |
local luadoc_tag_mod_and_value = luadoc_tag..'%[(.*)%](.*)'
|
23 | 23 |
|
24 | 24 |
-- assumes that the doc comment consists of distinct tag lines
|
25 | |
function parse_tags(text)
|
|
25 |
function parse_at_tags(text)
|
26 | 26 |
local lines = stringio.lines(text)
|
27 | 27 |
local preamble, line = tools.grab_while_not(lines,luadoc_tag)
|
28 | 28 |
local tag_items = {}
|
|
47 | 47 |
return preamble,tag_items
|
48 | 48 |
end
|
49 | 49 |
|
|
50 |
local colon_tag = '%s*(%a+):%s'
|
|
51 |
local colon_tag_value = colon_tag..'(.*)'
|
|
52 |
|
|
53 |
function parse_colon_tags (text)
|
|
54 |
local lines = stringio.lines(text)
|
|
55 |
local preamble, line = tools.grab_while_not(lines,colon_tag)
|
|
56 |
local tag_items, follows = {}
|
|
57 |
while line do
|
|
58 |
local tag, rest = line:match(colon_tag_value)
|
|
59 |
follows, line = tools.grab_while_not(lines,colon_tag)
|
|
60 |
append(tag_items,{tag, rest .. '\n' .. follows})
|
|
61 |
end
|
|
62 |
return preamble,tag_items
|
|
63 |
end
|
|
64 |
|
50 | 65 |
-- This takes the collected comment block, and uses the docstyle to
|
51 | 66 |
-- extract tags and values. Assume that the summary ends in a period or a question
|
52 | 67 |
-- mark, and everything else in the preamble is the description.
|
53 | 68 |
-- If a tag appears more than once, then its value becomes a list of strings.
|
54 | 69 |
-- Alias substitution and @TYPE NAME shortcutting is handled by Item.check_tag
|
55 | 70 |
local function extract_tags (s)
|
|
71 |
local preamble,tag_items
|
56 | 72 |
if s:match '^%s*$' then return {} end
|
57 | |
local preamble,tag_items = parse_tags(s)
|
|
73 |
if s:match ':%s' and not s:match '@%a' then
|
|
74 |
preamble,tag_items = parse_colon_tags(s)
|
|
75 |
else
|
|
76 |
preamble,tag_items = parse_at_tags(s)
|
|
77 |
end
|
58 | 78 |
local strip = tools.strip
|
59 | 79 |
local summary, description = preamble:match('^(.-[%.?])(%s.+)')
|
60 | 80 |
if not summary then
|
|
252 | 272 |
local line = t ~= nil and lineno()
|
253 | 273 |
if t ~= nil then
|
254 | 274 |
if item_follows then -- parse the item definition
|
255 | |
item_follows(tags,tok)
|
|
275 |
local err = item_follows(tags,tok)
|
|
276 |
if err then F:error(err) end
|
256 | 277 |
else
|
257 | 278 |
lang:parse_extra(tags,tok,case)
|
258 | 279 |
end
|