Module:Documentation

From Artifact Wiki
Jump to: navigation, search

Documentation for Module:Documentation [edit] [edit doc]

This module creates the Documentation template layout.

Preview


You are viewing a preview right now.

Usage


{{#invoke:Documentation|main
|fullpagename = {{FULLPAGENAME}}
|doclink = {{#ifexist:{{Documentation/DocLink}}|{{Documentation/DocLink}}|{{FULLPAGENAME}}}}
}}

local getArgs = require('Module:Arguments').main
local p = {}


function p.main(frame)
	local args = getArgs()
	return p._main(frame, args)
end


function p._main(frame, args)
  local fullpagename = frame.args['fullpagename']

  local pagename = string.gsub(fullpagename, "^w+:", "")
  local basepagename = string.gsub(pagename, "/doc$", "")
  local docbase = string.gsub(fullpagename, "/doc$", "")
  local doclink = frame.args['doclink']

  local editdoclink = string.format([=[<span class="plainlinks" style="font-size:11px;">
  [[https://artifactwiki.com/index.php?title=%s&action=edit edit doc]]
  </span>]=], string.gsub(doclink, " ", "_"))
  local editlink = string.format([=[<span class="plainlinks" style="font-size:11px;">
  [[https://artifactwiki.com/index.php?title=%s&action=edit edit]]
  </span>]=], string.gsub(basepagename, " ", "_"))

  local description = ""
  if(args['description']) then
    description = string.format([=[<p>
%s
</p>]=], args['description'])
  end

  local preview = ""
  if(args['preview']) then
    preview = string.format([=[
<h3>Preview</h3><hr/>
%s
<div style="clear: both;"></div>
]=], args['preview'])
  end

  local usage = ""
  if(args['usage']) then
    usage = string.format( [=[
<h3>Usage</h3><hr/>
%s
]=], args['usage'])
  end

  local output = string.format([==[__NOTOC__<div class="documentation" style="padding: 7px; padding-top: 0; display: block;"> 
<h2>[[%s|Documentation]] for [[%s|%s]]
%s <!-- Edit Link  -->
%s <!-- Edit Doc Link  --></h2>
%s <!-- Decription -->
%s <!-- Preview    -->
%s <!-- Usage      -->
</div>
]==], doclink, docbase, basepagename, editlink, editdoclink, description, preview, usage)

  return output
end

return p