Codebase list lua-ldoc / a560d75
relaxed argcheck-like style without at-signs; see example file steve donovan 11 years ago
4 changed file(s) with 33 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
113113
114114 local function parse_lua_function_header (tags,tok)
115115 tags.name = tools.get_fun_name(tok)
116 if not tags.name then return 'function has no name' end
116117 parse_lua_parameters(tags,tok)
117118 end
118119
2222 local luadoc_tag_mod_and_value = luadoc_tag..'%[(.*)%](.*)'
2323
2424 -- assumes that the doc comment consists of distinct tag lines
25 function parse_tags(text)
25 function parse_at_tags(text)
2626 local lines = stringio.lines(text)
2727 local preamble, line = tools.grab_while_not(lines,luadoc_tag)
2828 local tag_items = {}
4747 return preamble,tag_items
4848 end
4949
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
5065 -- This takes the collected comment block, and uses the docstyle to
5166 -- extract tags and values. Assume that the summary ends in a period or a question
5267 -- mark, and everything else in the preamble is the description.
5368 -- If a tag appears more than once, then its value becomes a list of strings.
5469 -- Alias substitution and @TYPE NAME shortcutting is handled by Item.check_tag
5570 local function extract_tags (s)
71 local preamble,tag_items
5672 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
5878 local strip = tools.strip
5979 local summary, description = preamble:match('^(.-[%.?])(%s.+)')
6080 if not summary then
252272 local line = t ~= nil and lineno()
253273 if t ~= nil then
254274 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
256277 else
257278 lang:parse_extra(tags,tok,case)
258279 end
338338 else
339339 t,name = 'iden',first
340340 end
341 if t ~= 'iden' then return nil end
341342 t,sep = tnext(tok)
342343 while sep == '.' or sep == ':' do
343344 append(res,name)
0 --- simplified LDoc style
1 module 'easy'
2
3 --- First one.
4 -- string: name
5 -- int: age
6 function first(name,age) end