Module:documentation: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
or mw.title.new(mw.title.getCurrentTitle().fullText .. "/documentation") | or mw.title.new(mw.title.getCurrentTitle().fullText .. "/documentation") | ||
if not doc.exists then | if not doc.exists then | ||
return '<div style="margin-left:1em;"><i>This page has no documentation. | return '<div style="margin-left:1em;"><i>This page has no documentation. Please [' .. doc:fullUrl{action="edit"} .. ' create it].</div>' | ||
end | end | ||
local doc_content = doc:getContent() | local doc_content = doc:getContent() | ||
Line 12: | Line 12: | ||
error("Documentation page exists but content is nil") | error("Documentation page exists but content is nil") | ||
end | end | ||
return '<div class="documentation">\nThe following documentation is located at [[' .. doc.fullText .. "]]. <sup> | return '<div class="documentation">\nThe following documentation is located at [[' .. doc.fullText .. "]]. <sup>[" .. doc:fullUrl{action="edit"} .. " edit]</sup>\n\n" .. doc:getContent() .. "\n</div>" | ||
end | end | ||
return export | return export |
Revision as of 13:24, 5 August 2023
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 '<div style="margin-left:1em;"><i>This page has no documentation. Please [' .. doc:fullUrl{action="edit"} .. ' create it].</div>'
end
local doc_content = doc:getContent()
if doc_content == nil then
error("Documentation page exists but content is nil")
end
return '<div class="documentation">\nThe following documentation is located at [[' .. doc.fullText .. "]]. <sup>[" .. doc:fullUrl{action="edit"} .. " edit]</sup>\n\n" .. doc:getContent() .. "\n</div>"
end
return export