@usage tag now works in module comments; annotations were borked
This commit is contained in:
parent
2b54ad1627
commit
40330487b0
|
@ -90,6 +90,15 @@ return [==[
|
||||||
# elseif module then -- module documentation
|
# elseif module then -- module documentation
|
||||||
<p>$(M(module.summary,module))</p>
|
<p>$(M(module.summary,module))</p>
|
||||||
<p>$(M(module.description,module))</p>
|
<p>$(M(module.description,module))</p>
|
||||||
|
# if module.usage then
|
||||||
|
# local li,il = use_li(module.usage)
|
||||||
|
<h3>Usage:</h3>
|
||||||
|
<ul>
|
||||||
|
# for usage in iter(module.usage) do
|
||||||
|
$(li)<pre class="example">$(usage)</pre>$(il)
|
||||||
|
# end -- for
|
||||||
|
</ul>
|
||||||
|
# end -- if usage
|
||||||
|
|
||||||
# if not ldoc.no_summary then
|
# if not ldoc.no_summary then
|
||||||
# -- bang out the tables of item types for this module (e.g Functions, Tables, etc)
|
# -- bang out the tables of item types for this module (e.g Functions, Tables, etc)
|
||||||
|
|
2
ldoc.lua
2
ldoc.lua
|
@ -58,7 +58,7 @@ ModuleMap:add_kind('function','Functions','Parameters')
|
||||||
ModuleMap:add_kind('table','Tables','Fields')
|
ModuleMap:add_kind('table','Tables','Fields')
|
||||||
ModuleMap:add_kind('field','Fields')
|
ModuleMap:add_kind('field','Fields')
|
||||||
ModuleMap:add_kind('lfunction','Local Functions','Parameters')
|
ModuleMap:add_kind('lfunction','Local Functions','Parameters')
|
||||||
ModuleMap:add_kind('annotation','Annotations')
|
ModuleMap:add_kind('annotation','Issues')
|
||||||
|
|
||||||
|
|
||||||
class.ProjectMap(KindMap)
|
class.ProjectMap(KindMap)
|
||||||
|
|
17
ldoc/doc.lua
17
ldoc/doc.lua
|
@ -73,13 +73,16 @@ known_tags._annotation_tags = {
|
||||||
local acount = 1
|
local acount = 1
|
||||||
|
|
||||||
function doc.expand_annotation_item (tags, last_item)
|
function doc.expand_annotation_item (tags, last_item)
|
||||||
local tag, value = next(tags)
|
if tags.summary ~= '' then return false end
|
||||||
if known_tags._annotation_tags[tag] then
|
for tag, value in pairs(tags) do
|
||||||
tags.class = 'annotation'
|
if known_tags._annotation_tags[tag] then
|
||||||
tags.summary = value
|
tags.class = 'annotation'
|
||||||
local item_name = last_item and last_item.tags.name or '?'
|
tags.summary = value
|
||||||
tags.name = item_name..'-'..tag..acount
|
local item_name = last_item and last_item.tags.name or '?'
|
||||||
acount = acount + 1
|
tags.name = item_name..'-'..tag..acount
|
||||||
|
acount = acount + 1
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ local tnext, append = lexer.skipws, table.insert
|
||||||
|
|
||||||
-- a pattern particular to LuaDoc tag lines: the line must begin with @TAG,
|
-- a pattern particular to LuaDoc tag lines: the line must begin with @TAG,
|
||||||
-- followed by the value, which may extend over several lines.
|
-- followed by the value, which may extend over several lines.
|
||||||
local luadoc_tag = '^%s*@(%a+)%s(.+)'
|
local luadoc_tag = '^%s*@(%a+)'
|
||||||
|
local luadoc_tag_value = luadoc_tag..'(.*)'
|
||||||
|
|
||||||
-- assumes that the doc comment consists of distinct tag lines
|
-- assumes that the doc comment consists of distinct tag lines
|
||||||
function parse_tags(text)
|
function parse_tags(text)
|
||||||
|
@ -25,7 +26,7 @@ function parse_tags(text)
|
||||||
local tag_items = {}
|
local tag_items = {}
|
||||||
local follows
|
local follows
|
||||||
while line do
|
while line do
|
||||||
local tag,rest = line:match(luadoc_tag)
|
local tag,rest = line:match(luadoc_tag_value)
|
||||||
follows, line = tools.grab_while_not(lines,luadoc_tag)
|
follows, line = tools.grab_while_not(lines,luadoc_tag)
|
||||||
append(tag_items,{tag, rest .. '\n' .. follows})
|
append(tag_items,{tag, rest .. '\n' .. follows})
|
||||||
end
|
end
|
||||||
|
@ -56,6 +57,7 @@ local function extract_tags (s)
|
||||||
tag = Item.check_tag(tags,tag)
|
tag = Item.check_tag(tags,tag)
|
||||||
value = strip(value)
|
value = strip(value)
|
||||||
local old_value = tags[tag]
|
local old_value = tags[tag]
|
||||||
|
|
||||||
if old_value then
|
if old_value then
|
||||||
if type(old_value)=='string' then tags[tag] = List{old_value} end
|
if type(old_value)=='string' then tags[tag] = List{old_value} end
|
||||||
tags[tag]:append(value)
|
tags[tag]:append(value)
|
||||||
|
|
Loading…
Reference in New Issue