Module:Documentation
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Documentation/doc
local p = {}
function p.main(frame)
local currentTitle = mw.title.getCurrentTitle()
local docTitle = mw.title.new(currentTitle.prefixedText .. '/doc')
local container = mw.html.create('div')
:addClass('template-documentation')
local header = container:tag('div')
:addClass('template-documentation-header')
header:tag('div')
:addClass('template-documentation-title')
:wikitext('<i class="fas fa-book-open"></i> Template documentation')
local links = header:tag('div')
:addClass('template-documentation-links')
if docTitle.exists then
links:wikitext(string.format(
'[ <i class="fas fa-eye"></i> [[%s|View]] ] ' ..
'[ <i class="fas fa-edit"></i> [%s Edit] ] ' ..
'[ <i class="fas fa-history"></i> [%s History] ] ' ..
'[ <i class="fas fa-sync-alt"></i> [%s Purge] ]',
docTitle.prefixedText,
docTitle:fullUrl('action=edit'),
docTitle:fullUrl('action=history'),
currentTitle:fullUrl('action=purge')
))
else
links:wikitext(string.format(
'[ <i class="fas fa-plus-circle" style="color:#d33;"></i> [%s Create documentation] ]',
docTitle:fullUrl('action=edit&redlink=1')
))
end
local content = container:tag('div')
:addClass('template-documentation-content')
if docTitle.exists then
content:wikitext(frame:expandTemplate{ title = docTitle.prefixedText })
else
content:wikitext('<i class="fas fa-exclamation-circle" style="color:#d33;"></i> This template has no documentation yet. Please click the link above to create it.')
end
return tostring(container)
end
return p