Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion template/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ return[[#
<table class="function_list">
# for _, item in sortedpairs(_file.globalvars) do
<tr>
<td class="name" nowrap="nowrap">$( fulllinkto(item) )</td>
<td class="name" nowrap="nowrap">$( purelinkto(item) )</td>
<td class="summary">$( format(item.shortdescription) )</td>
</tr>
# end
Expand Down
2 changes: 1 addition & 1 deletion template/functiontypedef.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ return [[#
# local paramline = "<code><em>"
# if param.type then
# local link = linkto( param.type )
# local name = prettyname( param.type )
# local name = purename( param.type )
# if link then
# paramline = paramline .. '<a href=\"' .. link .. '\">' .. name .. "</a>"
# else
Expand Down
2 changes: 1 addition & 1 deletion template/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return
# for _, module in sortedpairs( _index.modules ) do
# if module.tag ~= 'index' then
<tr>
<td class="name" nowrap="nowrap">$( fulllinkto(module) )</td>
<td class="name" nowrap="nowrap">$( purelinkto(module) )</td>
<td class="summary">$( module.description and format(module.shortdescription) )</td>
</tr>
# end
Expand Down
4 changes: 2 additions & 2 deletions template/index/recordtypedef.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ return [[#
<table class="function_list">
# if calldef then
<tr>
<td class="name" nowrap="nowrap">$( fulllinkto(calldef,_recordtypedef) )</td>
<td class="name" nowrap="nowrap">$( purelinkto(calldef,_recordtypedef) )</td>
<td class="summary">$( format(calldef.shortdescription) )</td>
</tr>
# end
# for _, item in sortedpairs( _recordtypedef.fields ) do
<tr>
<td class="name" nowrap="nowrap">$( fulllinkto(item) )</td>
<td class="name" nowrap="nowrap">$( purelinkto(item) )</td>
<td class="summary">$( format(item.shortdescription) )</td>
</tr>
# end
Expand Down
6 changes: 3 additions & 3 deletions template/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
<em>$( link )</em>
# else
<em>$(prettyname(_item.type))</em>
<em>$(purename(_item.type))</em>
# end
#end
<a id="$(anchor(_item))" >
<strong>$( prettyname(_item) )</strong>
<strong>$( purename(_item) )</strong>
</a>
</dt>
<dd>
Expand Down
1 change: 1 addition & 0 deletions template/page.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return
# for _, header in ipairs(_page.headers) do
$(header)
# end
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
#end
<body>
Expand Down
4 changes: 2 additions & 2 deletions template/recordtypedef.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ return [[#
# -- Inheritance
# --
#if _recordtypedef.supertype then
<h$(i)> Extends $( fulllinkto(_recordtypedef.supertype)) </h$(i)>
<h$(i)> Extends $( purelinkto(_recordtypedef.supertype)) </h$(i)>
#end
# --
# -- Descriptions
Expand Down Expand Up @@ -63,7 +63,7 @@ return [[#
<dl class="function">
<dt>
<a id="$(anchor(calldef,_recordtypedef))" >
<strong>$( prettyname(calldef,_recordtypedef) )</strong>
<strong>$( purename(calldef,_recordtypedef) )</strong>
</a>
</dt>
<dd>
Expand Down
22 changes: 22 additions & 0 deletions template/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions templateengine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="%s">%s</a>', ref, name)
end

---
-- Provide a full link to an element using `prettyname` and `linkto`.
-- Default implementation is for HTML.
Expand All @@ -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
Expand Down