Module:documentation

From Laenkea
Revision as of 16:57, 5 August 2023 by Maria (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:documentation/documentation

local export = {}

function export.show(frame)
	local source = frame.args[1] or frame.args["source"]
	local doc = ((type(source) == "string" and source ~= "") and mw.title.new(source))
		or mw.title.new(mw.title.getCurrentTitle().fullText .. "/documentation")
	if not doc.exists then
		return '\n<div style="margin-left:1em;">\n<i>This page has no documentation. Please <span class="plainlinks">[' .. doc:fullUrl{action="edit"} .. ' create it]</span>.</i>\n</div>\n'
	end
	local doc_content = frame:expandTemplate{title=doc.fullText}
	return '\n<div class="documentation">\n<i>The following documentation is located at [[' .. doc.fullText .. ']]. <sup><span class="plainlinks">[[' .. doc:fullUrl{action="edit"} .. " edit]]</span></sup></i>\n\n" .. (doc_content or "") .. "\n</div>\n"
end

return export