diff --git a/template/file.lua b/template/file.lua index ef9e1f9..bb7d56f 100644 --- a/template/file.lua +++ b/template/file.lua @@ -42,7 +42,7 @@ return[[# # for _, item in sortedpairs(_file.globalvars) do - + # end diff --git a/template/functiontypedef.lua b/template/functiontypedef.lua index 72e68c8..4de7d43 100644 --- a/template/functiontypedef.lua +++ b/template/functiontypedef.lua @@ -45,7 +45,7 @@ return [[# # local paramline = "" # if param.type then # local link = linkto( param.type ) -# local name = prettyname( param.type ) +# local name = purename( param.type ) # if link then # paramline = paramline .. '' .. name .. "" # else diff --git a/template/index.lua b/template/index.lua index 28c0605..426eb25 100644 --- a/template/index.lua +++ b/template/index.lua @@ -18,7 +18,7 @@ return # for _, module in sortedpairs( _index.modules ) do # if module.tag ~= 'index' then - + # end diff --git a/template/index/recordtypedef.lua b/template/index/recordtypedef.lua index 2d4ab13..b23a6ae 100644 --- a/template/index/recordtypedef.lua +++ b/template/index/recordtypedef.lua @@ -16,13 +16,13 @@ return [[#
$( fulllinkto(item) )$( purelinkto(item) ) $( format(item.shortdescription) )
$( fulllinkto(module) )$( purelinkto(module) ) $( module.description and format(module.shortdescription) )
# if calldef then - + # end # for _, item in sortedpairs( _recordtypedef.fields ) do - + # end diff --git a/template/item.lua b/template/item.lua index 2faa026..5b88e6f 100644 --- a/template/item.lua +++ b/template/item.lua @@ -22,15 +22,15 @@ return # -- #if _item.type and (not typedef or typedef.tag ~= 'functiontypedef') then # --Show link only when available -# local link = fulllinkto(_item.type) +# local link = purelinkto(_item.type) # if link then $( link ) # else - $(prettyname(_item.type)) + $(purename(_item.type)) # end #end -$( prettyname(_item) ) +$( purename(_item) )
diff --git a/template/page.lua b/template/page.lua index d233efc..27f26a0 100644 --- a/template/page.lua +++ b/template/page.lua @@ -17,6 +17,7 @@ return # for _, header in ipairs(_page.headers) do $(header) # end + #end diff --git a/template/recordtypedef.lua b/template/recordtypedef.lua index e5418c9..97f7833 100644 --- a/template/recordtypedef.lua +++ b/template/recordtypedef.lua @@ -14,7 +14,7 @@ return [[# # -- Inheritance # -- #if _recordtypedef.supertype then - Extends $( fulllinkto(_recordtypedef.supertype)) + Extends $( purelinkto(_recordtypedef.supertype)) #end # -- # -- Descriptions @@ -63,7 +63,7 @@ return [[#
- $( prettyname(calldef,_recordtypedef) ) + $( purename(calldef,_recordtypedef) )
diff --git a/template/utils.lua b/template/utils.lua index bf9f9e0..357552d 100644 --- a/template/utils.lua +++ b/template/utils.lua @@ -363,6 +363,28 @@ function M.prettyname( apiobject, ... ) return nil, string.format('No pretty name for `%s.', tag) end +--- +-- Provide human readable overview from an API model element +-- +-- Resolve all element needed to summurize nicely an element form API model. +-- This element is not excaped. +-- @usage $ print( purename(item) ) +-- module:somefunction(secondparameter) +-- @function [parent = #docutils] +-- @param apiobject Object form API model +-- @result #string Human readable description of given element. +-- @result #nil, #string In case of error. +function M.purename( apiobject, ... ) + local tag = apiobject.tag + if M.prettynametypes[tag] then + local prettyname = M.prettynametypes[tag](apiobject,...) + return prettyname + elseif not tag then + return nil, 'No pretty name available as no tag has been provided.' + end + return nil, string.format('No pretty name for `%s.', tag) +end + --- -- Just make a string print table in HTML. -- @function [parent = #docutils] securechevrons diff --git a/templateengine.lua b/templateengine.lua index 607a600..0f1bd00 100644 --- a/templateengine.lua +++ b/templateengine.lua @@ -85,6 +85,19 @@ local function format(string) return M.env.markdown( string ) end +--- +-- Provide a full link to an element using `purename` and `linkto`. +-- The purename is not escaped. +-- Default implementation is for HTML. +local function purelinkto(o,...) + local ref = M.env.linkto(o,...) + local name = M.env.purename(o,...) + if not ref then + return name + end + return string.format('%s', ref, name) +end + --- -- Provide a full link to an element using `prettyname` and `linkto`. -- Default implementation is for HTML. @@ -107,6 +120,7 @@ local defaultenv = { applytemplate = M.applytemplate, format = format, linkto = function(str) return str end, + purelinkto = purelinkto, fulllinkto = fulllinkto, prettyname = function(s) return s end, getelement = function(s) return nil end
$( fulllinkto(calldef,_recordtypedef) )$( purelinkto(calldef,_recordtypedef) ) $( format(calldef.shortdescription) )
$( fulllinkto(item) )$( purelinkto(item) ) $( format(item.shortdescription) )