<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FJeblad%2FLuaDoc</id>
	<title>Module:Sandbox/Jeblad/LuaDoc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FJeblad%2FLuaDoc"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Jeblad/LuaDoc&amp;action=history"/>
	<updated>2026-05-23T21:45:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Jeblad/LuaDoc&amp;diff=145597&amp;oldid=prev</id>
		<title>imported&gt;Legoktm: Replace Module:No globals with require( &quot;strict&quot; )</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Jeblad/LuaDoc&amp;diff=145597&amp;oldid=prev"/>
		<updated>2022-10-23T21:14:53Z</updated>

		<summary type="html">&lt;p&gt;Replace &lt;a href=&quot;/research/Module:No_globals&quot; title=&quot;Module:No globals&quot;&gt;Module:No globals&lt;/a&gt; with require( &amp;quot;strict&amp;quot; )&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
This code is work in progress, with all the problems that imply.&lt;br /&gt;
Note that documentation in this module is made to test various aspects of the&lt;br /&gt;
module itself. Because of this the documentation isn&amp;#039;t complete, and can even&lt;br /&gt;
be bogus.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
--- Format documentation of a module and make it linkable&lt;br /&gt;
-- The module makes some assumptions about the layout, basically the same as&lt;br /&gt;
-- [[JavaDoc]] and [[LuaDoc]], but does not follow those examples strictly. Especially,&lt;br /&gt;
-- it makes no attempt to do a deeper analysis of the provided code.&lt;br /&gt;
-- @author [[User:Jeblad]]&lt;br /&gt;
-- @copyright [mailto:jeblad@gmail.com]&lt;br /&gt;
-- @license [https://creativecommons.org/licenses/by-sa/3.0/ Creative Commons: Attribution-ShareAlike 3.0 Unported] (CC BY-SA 3.0) &lt;br /&gt;
local luadoc = {}&lt;br /&gt;
&lt;br /&gt;
-- don&amp;#039;t pollute with globals&lt;br /&gt;
require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
--- Registry for fragment types&lt;br /&gt;
local fragTypes = {}&lt;br /&gt;
&lt;br /&gt;
--- Registry for access points&lt;br /&gt;
local access = {}&lt;br /&gt;
&lt;br /&gt;
--- Table acting as a baseclass for fragments&lt;br /&gt;
-- @access private&lt;br /&gt;
-- @var ..?&lt;br /&gt;
-- @field _class string acting as a class marker for the fragment&lt;br /&gt;
-- @field _summary table holding the summary (the first line of the description) for the fragment&lt;br /&gt;
-- @field _description table holding the description (the remaining text of the description) for the fragment&lt;br /&gt;
local Frag = {}&lt;br /&gt;
Frag.__index = Frag&lt;br /&gt;
&lt;br /&gt;
setmetatable(Frag, {&lt;br /&gt;
  __call = function (cls, ...)&lt;br /&gt;
    local self = setmetatable({}, cls)&lt;br /&gt;
    self:_init(...)&lt;br /&gt;
    return self&lt;br /&gt;
  end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--- Initialiser for the Frag class&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Frag:_init( t )&lt;br /&gt;
  self[&amp;#039;_class&amp;#039;] = t[&amp;#039;_class&amp;#039;]&lt;br /&gt;
  self[&amp;#039;_weight&amp;#039;] = t[&amp;#039;_weight&amp;#039;]&lt;br /&gt;
  self[&amp;#039;_summary&amp;#039;] = t[&amp;#039;_summary&amp;#039;]&lt;br /&gt;
  self[&amp;#039;_description&amp;#039;] = t[&amp;#039;_description&amp;#039;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given class viewed as a possible Frag instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Frag.weightOfClass( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	weight = weight + Frag.weightOfClassDescription( t )&lt;br /&gt;
	weight = weight + Frag.weightOfClassSignature( t[&amp;#039;_code&amp;#039;] )&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given description viewed as a possible Frag instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Frag.weightOfClassDescription( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given signature viewed as a possible Frag instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Frag.weightOfClassSignature( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the class member field&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
function Frag:renderClass( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-tagline&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_class&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the weight member field&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
function Frag:renderWeight( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-weight&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_weight&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the summary member field&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
function Frag:renderSummary( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-summary&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_summary&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the description member field&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
function Frag:renderDescription( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-description&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_description&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the total Frag structure&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
-- @return table the extended parent&lt;br /&gt;
function Frag:render( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-fragment&amp;#039; )&lt;br /&gt;
	html&lt;br /&gt;
		:node(self:renderClass(t))&lt;br /&gt;
		:node(self:renderWeight(t))&lt;br /&gt;
		:node(self:renderSummary(t))&lt;br /&gt;
		:node(self:renderDescription(t))&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Table acting as a subclass for varables&lt;br /&gt;
-- @var ..?&lt;br /&gt;
-- @field _var string ..?&lt;br /&gt;
-- @access private&lt;br /&gt;
local Var = {}&lt;br /&gt;
Var.__index = Var&lt;br /&gt;
&lt;br /&gt;
fragTypes[&amp;#039;variable&amp;#039;] = Var&lt;br /&gt;
&lt;br /&gt;
setmetatable(Var, {&lt;br /&gt;
  __index = Frag,&lt;br /&gt;
  __call = function (cls, ...)&lt;br /&gt;
    local self = setmetatable({}, cls)&lt;br /&gt;
    self:_init(...)&lt;br /&gt;
    return self&lt;br /&gt;
  end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--- Initialiser for the Var class&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Var:_init( t )&lt;br /&gt;
  Frag._init(self, t)&lt;br /&gt;
  self[&amp;#039;_var&amp;#039;] = t[&amp;#039;_var&amp;#039;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given class viewed as a possible Var instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Var.weightOfClass( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	weight = weight + Var.weightOfClassDescription( t )&lt;br /&gt;
	weight = weight + Var.weightOfClassSignature( t[&amp;#039;_code&amp;#039;] )&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given description viewed as a possible Var instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Var.weightOfClassDescription( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not t then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Frag.weightOfClassDescription(t)&lt;br /&gt;
	weight = weight + (t._class == &amp;#039;variable&amp;#039; and 100 or 0)&lt;br /&gt;
	weight = weight + (t._var and 50 or 0)&lt;br /&gt;
	weight = weight + (t._field and 50 or 0)&lt;br /&gt;
	weight = weight - (t._param and 50 or 0)&lt;br /&gt;
	weight = weight - (t._return and 50 or 0)&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given signature viewed as a possible Var instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Var.weightOfClassSignature( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not s then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Frag.weightOfClassSignature(s)&lt;br /&gt;
	local exclude = {&lt;br /&gt;
		[&amp;#039;function&amp;#039;] = true,&lt;br /&gt;
	}&lt;br /&gt;
	local loc, nme = s:match(&amp;#039;(local)%s+([_%a][_%a%d]*)&amp;#039;)&lt;br /&gt;
	if loc and not exclude[nme] then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	local nme, eqv = s:match(&amp;#039;([_%a][_%a%d]*)%s+(=)&amp;#039;)&lt;br /&gt;
	if eqv and not exclude[nme] then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Var:renderVar( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-variable&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_var&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the total Var structure&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
-- @return table the extended parent&lt;br /&gt;
function Var:render( t )&lt;br /&gt;
	local html = Frag.render(self, t)&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Table acting as a subclass for modules&lt;br /&gt;
-- @var ..?&lt;br /&gt;
-- @access private&lt;br /&gt;
local Mod = {}&lt;br /&gt;
Mod.__index = Mod&lt;br /&gt;
&lt;br /&gt;
fragTypes[&amp;#039;module&amp;#039;] = Mod&lt;br /&gt;
&lt;br /&gt;
setmetatable(Mod, {&lt;br /&gt;
  __index = Frag,&lt;br /&gt;
  __call = function (cls, ...)&lt;br /&gt;
    local self = setmetatable({}, cls)&lt;br /&gt;
    self:_init(...)&lt;br /&gt;
    return self&lt;br /&gt;
  end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--- Initialiser for the Mod class&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Mod:_init( t )&lt;br /&gt;
  Frag._init(self, t)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given class viewed as a possible Frag instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Mod.weightOfClass( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	weight = weight + Mod.weightOfClassDescription( t )&lt;br /&gt;
	weight = weight + Mod.weightOfClassSignature( t[&amp;#039;_code&amp;#039;] )&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given description viewed as a possible Mod instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Mod.weightOfClassDescription( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not t then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Var.weightOfClassDescription(t)&lt;br /&gt;
	weight = weight + (t._class == &amp;#039;module&amp;#039; and 100 or 0)&lt;br /&gt;
	weight = weight - (t._var and 10 or 0)&lt;br /&gt;
	weight = weight - (t._field and 10 or 0)&lt;br /&gt;
	weight = weight - (t._param and 10 or 0)&lt;br /&gt;
	weight = weight - (t._return and 10 or 0)&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given signature viewed as a possible Mod instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Mod.weightOfClassSignature( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not s then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Var.weightOfClassSignature(s)&lt;br /&gt;
	if s:match(&amp;#039;^[ \t]*[\n\r]&amp;#039;) then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the total Mod structure&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
-- @return table the extended parent&lt;br /&gt;
function Mod:render( t )&lt;br /&gt;
	local html = Frag.render(self, t)&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Table acting as a subclass for modules&lt;br /&gt;
-- @var ..?&lt;br /&gt;
-- @access private&lt;br /&gt;
local Ret = {}&lt;br /&gt;
Ret.__index = Ret&lt;br /&gt;
&lt;br /&gt;
fragTypes[&amp;#039;return&amp;#039;] = Ret&lt;br /&gt;
&lt;br /&gt;
setmetatable(Ret, {&lt;br /&gt;
  __index = Frag,&lt;br /&gt;
  __call = function (cls, ...)&lt;br /&gt;
    local self = setmetatable({}, cls)&lt;br /&gt;
    self:_init(...)&lt;br /&gt;
    return self&lt;br /&gt;
  end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--- Initialiser for the ret class&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Ret:_init( t )&lt;br /&gt;
  Frag._init(self, t)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given class viewed as a possible Ret instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Ret.weightOfClass( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	weight = weight + Ret.weightOfClassDescription( t )&lt;br /&gt;
	weight = weight + Ret.weightOfClassSignature( t[&amp;#039;_code&amp;#039;] )&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given description viewed as a possible ret instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Ret.weightOfClassDescription( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not t then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Frag.weightOfClassDescription(t)&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given signature viewed as a possible Ret instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Ret.weightOfClassSignature( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not s then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Frag.weightOfClassSignature(s)&lt;br /&gt;
	if s:match(&amp;#039;(return)%s+([_%a][_%a%d]*)&amp;#039;) then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the total Ret structure&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
-- @return table the extended parent&lt;br /&gt;
function Ret:render( t )&lt;br /&gt;
	local html = Frag.render(self, t)&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Table acting as a subclass for functions&lt;br /&gt;
-- @var ..?&lt;br /&gt;
-- @field _param table holding all params to the function&lt;br /&gt;
-- @field _return table holding all returns from the function&lt;br /&gt;
-- @access private&lt;br /&gt;
local Func = {}&lt;br /&gt;
Func.__index = Func&lt;br /&gt;
&lt;br /&gt;
fragTypes[&amp;#039;function&amp;#039;] = Func&lt;br /&gt;
&lt;br /&gt;
setmetatable(Func, {&lt;br /&gt;
  __index = Frag,&lt;br /&gt;
  __call = function (cls, ...)&lt;br /&gt;
    local self = setmetatable({}, cls)&lt;br /&gt;
    self:_init(...)&lt;br /&gt;
    return self&lt;br /&gt;
  end,&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--- Initialiser for the Func class&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Func:_init( t )&lt;br /&gt;
  Frag._init(self, t)&lt;br /&gt;
  self[&amp;#039;_param&amp;#039;] = t[&amp;#039;_param&amp;#039;]&lt;br /&gt;
  self[&amp;#039;_return&amp;#039;] = t[&amp;#039;_return&amp;#039;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given class viewed as a possible Func instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Func.weightOfClass( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	weight = weight + Func.weightOfClassDescription( t )&lt;br /&gt;
	weight = weight + Func.weightOfClassSignature( t[&amp;#039;_code&amp;#039;] )&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given description viewed as a possible Func instance&lt;br /&gt;
-- @param t table holding data used during initialization&lt;br /&gt;
function Func.weightOfClassDescription( t )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not t then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Var.weightOfClassDescription(t)&lt;br /&gt;
	weight = weight + (t._class == &amp;#039;function&amp;#039; and 100 or 0)&lt;br /&gt;
	weight = weight - (t._var and 50 or 0)&lt;br /&gt;
	weight = weight - (t._field and 50 or 0)&lt;br /&gt;
	weight = weight + (t._param and 50 or 0)&lt;br /&gt;
	weight = weight + (t._return and 50 or 0)&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Weight of the given signature viewed as a possible Func instance&lt;br /&gt;
-- @param s string holding a code snippet&lt;br /&gt;
function Func.weightOfClassSignature( s )&lt;br /&gt;
	local weight = 0&lt;br /&gt;
	if not s then&lt;br /&gt;
		return weight&lt;br /&gt;
	end&lt;br /&gt;
	weight = weight + Var.weightOfClassSignature(s)&lt;br /&gt;
	local include = {&lt;br /&gt;
		[&amp;#039;function&amp;#039;] = true,&lt;br /&gt;
	}&lt;br /&gt;
	local loc, nme = s:match(&amp;#039;(local)%s+([_%a][_%a%d]*)&amp;#039;)&lt;br /&gt;
	if loc and include[nme] then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	local eqv,nme = s:match(&amp;#039;(=)%s+([_%a][_%a%d]*)&amp;#039;)&lt;br /&gt;
	if eqv and include[nme] then&lt;br /&gt;
		weight = weight + 25&lt;br /&gt;
	end&lt;br /&gt;
	return weight&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Func:renderParam( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-parameter&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_param&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Func:renderReturn( t )&lt;br /&gt;
	local html = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	:addClass( &amp;#039;luadoc-return&amp;#039; )&lt;br /&gt;
	:wikitext( self[&amp;#039;_return&amp;#039;] )&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Render method for the total Func structure&lt;br /&gt;
-- @param parent table reference to the containing element&lt;br /&gt;
-- @param t table for optional data used while rendering&lt;br /&gt;
-- @return table the parent make the method chainable&lt;br /&gt;
-- @return table the extended parent&lt;br /&gt;
function Func:render( t )&lt;br /&gt;
	local html = Frag.render(self, t)&lt;br /&gt;
	return html&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Load page identified by text and namespace&lt;br /&gt;
-- @since somedate&lt;br /&gt;
-- @param text string base name and any subparts&lt;br /&gt;
-- @param namespace string containing the namespace on a valid form&lt;br /&gt;
-- @return string in a raw form according to the content model&lt;br /&gt;
-- @throw string verbatim &amp;#039;Unknown&amp;#039; if can&amp;#039;t find a valid title object&lt;br /&gt;
-- @throw string verbatim &amp;#039;Got no content&amp;#039; if can&amp;#039;t get content&lt;br /&gt;
local function loadDoc( text, namespace )&lt;br /&gt;
	local title = mw.title.new( text, namespace )&lt;br /&gt;
	assert( title, &amp;#039;Unknown title&amp;#039;)&lt;br /&gt;
	local content = title:getContent()&lt;br /&gt;
	assert( content, &amp;#039;Got no content&amp;#039; )&lt;br /&gt;
	return content&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Create a fragment according to a best guess&lt;br /&gt;
-- @param frag table containing a single fragment&lt;br /&gt;
-- @return table as a subclass of Frag&lt;br /&gt;
local function createFragment( frag )&lt;br /&gt;
	local maxWeight = -1000&lt;br /&gt;
	local clss = nil&lt;br /&gt;
	local name = nil&lt;br /&gt;
	for k,v in pairs(fragTypes) do&lt;br /&gt;
		local weight = v.weightOfClass( frag )&lt;br /&gt;
		if weight &amp;gt; maxWeight then&lt;br /&gt;
			maxWeight = weight&lt;br /&gt;
			clss = v&lt;br /&gt;
			name = k&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	frag._weight = maxWeight&lt;br /&gt;
	&lt;br /&gt;
	if maxWeight&amp;gt;=0 then&lt;br /&gt;
		frag._class = name&lt;br /&gt;
		return clss( frag )&lt;br /&gt;
		--return Frag( frag )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	frag._class = &amp;#039;unknown&amp;#039;&lt;br /&gt;
	return Frag(frag)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Strip provided code for block comments&lt;br /&gt;
-- @since somedate&lt;br /&gt;
-- @param code string providing the program&lt;br /&gt;
-- @return string clensed for block comments&lt;br /&gt;
local function stripBlockComments( code )&lt;br /&gt;
	local collapse = function(s) return s:gsub(&amp;#039;^%-%-%[(=*)%[.*]%1%]$&amp;#039;, &amp;#039;&amp;#039;) end&lt;br /&gt;
	return code:gsub(&amp;#039;(%-%-+%b[])&amp;#039;, collapse)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Split provided code in fragments&lt;br /&gt;
-- @x-access public this should be public if everything works out&lt;br /&gt;
-- @since somedate&lt;br /&gt;
-- @param code string providing the program&lt;br /&gt;
-- @return table of fragments&lt;br /&gt;
local function splitOutFragments( code )&lt;br /&gt;
	local fragments = {}&lt;br /&gt;
	local fragNum = 0&lt;br /&gt;
	for slice in mw.text.gsplit(code, &amp;quot;\n%s*%-%-%-%s*&amp;quot;) do&lt;br /&gt;
		fragNum = 1+fragNum&lt;br /&gt;
		if not slice:match(&amp;#039;^%s*$&amp;#039;) then&lt;br /&gt;
			local fragment = { [&amp;#039;_description&amp;#039;] = { &amp;#039;&amp;#039; }, [&amp;#039;_code&amp;#039;] = { &amp;#039;&amp;#039; } }&lt;br /&gt;
			if fragNum == 1 then&lt;br /&gt;
				fragment._class = #fragment == 1 and &amp;#039;module&amp;#039; or &amp;#039;unknown&amp;#039;&lt;br /&gt;
				slice = slice:gsub( &amp;#039;^%s*%-%-%-[\ \t]*([^\n\r]+)[\n\r]*&amp;#039;,&lt;br /&gt;
					function(str) fragment._summary = str; return &amp;#039;&amp;#039; end )&lt;br /&gt;
			else&lt;br /&gt;
				fragment._class = #fragment == 1 and &amp;#039;module&amp;#039; or &amp;#039;unknown&amp;#039;&lt;br /&gt;
				slice = slice:gsub( &amp;#039;^%s*([^\n\r]+)[\n\r]*&amp;#039;,&lt;br /&gt;
					function(str) fragment._summary = str; return &amp;#039;&amp;#039; end )&lt;br /&gt;
			end&lt;br /&gt;
			local last = &amp;#039;_description&amp;#039;&lt;br /&gt;
			for line in slice:gmatch( &amp;#039;([^\n\r]+)&amp;#039; ) do&lt;br /&gt;
				if line:match( &amp;#039;^%s*%-%-&amp;#039; ) then&lt;br /&gt;
					local attr, text = line:match( &amp;#039;^%s*%-%-%s*@(%a+)%s+(.*)$&amp;#039; )&lt;br /&gt;
					if attr then&lt;br /&gt;
						last = &amp;#039;_&amp;#039;..attr&lt;br /&gt;
						if not fragment[last] then&lt;br /&gt;
							fragment[last] = {}&lt;br /&gt;
						end&lt;br /&gt;
						fragment[last][1+#fragment[last]] = text&lt;br /&gt;
					else&lt;br /&gt;
						local text = line:match( &amp;#039;^%s*%-%-%s*(.*)$&amp;#039; )&lt;br /&gt;
						if fragment[last][#fragment[last]]:match(&amp;#039;^%s*$&amp;#039;) then&lt;br /&gt;
							fragment[last][#fragment[last]] = text&lt;br /&gt;
						else&lt;br /&gt;
							local joiner = text:match(&amp;#039;^%s*$&amp;#039;) and &amp;#039;\n&amp;#039; or &amp;#039; &amp;#039;&lt;br /&gt;
							fragment[last][#fragment[last]] =&lt;br /&gt;
								fragment[last][#fragment[last]] .. joiner .. text&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					last = &amp;#039;_code&amp;#039;&lt;br /&gt;
					fragment[last][#fragment[last]] =&lt;br /&gt;
						fragment[last][#fragment[last]] .. &amp;#039;\n&amp;#039; .. line&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			fragment._description = fragment._description and table.concat(fragment._description, &amp;#039;\n&amp;#039;) or nil&lt;br /&gt;
			fragment._code = fragment._code and table.concat(fragment._code, &amp;#039;\n&amp;#039;) or nil&lt;br /&gt;
			if fragment._access then&lt;br /&gt;
				local access = { [&amp;#039;public&amp;#039;] = 0, [&amp;#039;private&amp;#039;] = 0 }&lt;br /&gt;
				for _,v in ipairs(fragment._access) do&lt;br /&gt;
					access[v] = (access[v] or 0) + 500&lt;br /&gt;
				end&lt;br /&gt;
				fragment._access = access&lt;br /&gt;
			end&lt;br /&gt;
			fragments[1+#fragments] = fragment&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return fragments&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Parse provided code&lt;br /&gt;
-- @x-access public this will be private if everything works out&lt;br /&gt;
-- @deprecated somedate this call will not be used&lt;br /&gt;
-- @param code string providing the program&lt;br /&gt;
-- @return table of fragments&lt;br /&gt;
local function parseCode( code )&lt;br /&gt;
	local fragments = {}&lt;br /&gt;
	local fragment = { [&amp;quot;_class&amp;quot;] = &amp;#039;module&amp;#039;, [&amp;quot;lines&amp;quot;] = 0 }&lt;br /&gt;
	local last = nil&lt;br /&gt;
	for line in code:gmatch( &amp;#039;([^\n]+)&amp;#039; ) do&lt;br /&gt;
		local desc = line:match( &amp;#039;^\s*%-%-%-\s*(.+)&amp;#039; )&lt;br /&gt;
		if desc then&lt;br /&gt;
			if fragment.lines &amp;gt; 0 then&lt;br /&gt;
				fragments[1+#fragments] = parseFragment( fragment )&lt;br /&gt;
				fragment = { [&amp;quot;_class&amp;quot;] = nil, [&amp;quot;lines&amp;quot;] = 0 }&lt;br /&gt;
			end&lt;br /&gt;
			fragment ={}&lt;br /&gt;
			last = &amp;#039;_description&amp;#039;&lt;br /&gt;
			fragment[last] = desc&lt;br /&gt;
		else&lt;br /&gt;
			if line:match( &amp;#039;^\s*--&amp;#039; ) then&lt;br /&gt;
				local attr, text = line:match( &amp;#039;^\s*%-%-\s*@(\w+)\s+(.*)&amp;#039; )&lt;br /&gt;
				if attr then&lt;br /&gt;
					last = &amp;#039;_&amp;#039;..attr&lt;br /&gt;
					if not fragment[last] then&lt;br /&gt;
						fragment[last] = {}&lt;br /&gt;
					end&lt;br /&gt;
					fragment[last][1+#fragment[last]] = text&lt;br /&gt;
				else&lt;br /&gt;
					local text = line:match( &amp;#039;^\s*--\s*(.*)&amp;#039; )&lt;br /&gt;
					fragment[last][#fragment[last]] = text&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				last = &amp;#039;_code&amp;#039;&lt;br /&gt;
				fragment[last] = line&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- @todo check if last fragment is empty&lt;br /&gt;
	return fragments&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
if 1 or _G[&amp;#039;_BDD&amp;#039;] then&lt;br /&gt;
	luadoc.Frag = Frag&lt;br /&gt;
	luadoc.Mod = Mod&lt;br /&gt;
	luadoc.Ret = Ret&lt;br /&gt;
	luadoc.Var = Var&lt;br /&gt;
	luadoc.Func = Func&lt;br /&gt;
	luadoc.loadDoc = loadDoc&lt;br /&gt;
	luadoc.createFragment = createFragment&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Invokable method to build a document&lt;br /&gt;
-- @access public&lt;br /&gt;
-- @param frame table for contextual information&lt;br /&gt;
-- @return string for display on a rendered page&lt;br /&gt;
function luadoc.build( frame )&lt;br /&gt;
	local docs = {}&lt;br /&gt;
	for _,v in ipairs( frame.args ) do&lt;br /&gt;
		local str = mw.text.trim( v )&lt;br /&gt;
		if str == &amp;#039;&amp;#039; then&lt;br /&gt;
			-- do nothing&lt;br /&gt;
		else&lt;br /&gt;
			-- local name or canonical name, at english only canonical name&lt;br /&gt;
			if str:match( &amp;#039;^[mM]odule:&amp;#039; ) then&lt;br /&gt;
				local namespace = str:match( &amp;#039;^(%S-)%s*:&amp;#039; )&lt;br /&gt;
				local text = str:match( &amp;#039;:%s*(.-)%s*$&amp;#039; )&lt;br /&gt;
				local code = loadDoc( text, namespace )&lt;br /&gt;
				local stripped = stripBlockComments( code )&lt;br /&gt;
				docs[1+#docs] = splitOutFragments( stripped )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local parent = mw.html.create( &amp;#039;div&amp;#039; )&lt;br /&gt;
	for _,frags in ipairs( docs ) do&lt;br /&gt;
		for _,v in ipairs( frags ) do&lt;br /&gt;
			--local pre = mw.html.create( &amp;#039;pre&amp;#039; )&lt;br /&gt;
			local frag = createFragment(v)&lt;br /&gt;
			parent:node(frag:render())&lt;br /&gt;
			--parent:node(v:render())&lt;br /&gt;
			--pre:wikitext(mw.dumpObject(Frag(v):render()))&lt;br /&gt;
			--parent:node(pre)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return parent&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Final return of the provided module&lt;br /&gt;
return luadoc&lt;/div&gt;</summary>
		<author><name>imported&gt;Legoktm</name></author>
	</entry>
</feed>