Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
m Replaced content with "-- Module:Documentation 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') -- 标题及图标 (使用 FontAwesome) head..." Tag: Replaced |
mNo edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
| Line 6: | Line 5: | ||
local docTitle = mw.title.new(currentTitle.prefixedText .. '/doc') | local docTitle = mw.title.new(currentTitle.prefixedText .. '/doc') | ||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
:addClass('template-documentation') | :addClass('template-documentation') | ||
local header = container:tag('div') | local header = container:tag('div') | ||
:addClass('template-documentation-header') | :addClass('template-documentation-header') | ||
header:tag('div') | header:tag('div') | ||
:addClass('template-documentation-title') | :addClass('template-documentation-title') | ||
:wikitext('<i class="fas fa-book-open"></i> | :wikitext('<i class="fas fa-book-open"></i> Template documentation') | ||
local links = header:tag('div') | local links = header:tag('div') | ||
:addClass('template-documentation-links') | :addClass('template-documentation-links') | ||
if docTitle.exists then | if docTitle.exists then | ||
links:wikitext(string.format( | links:wikitext(string.format( | ||
'[ <i class="fas fa-eye"></i> [[%s| | '[ <i class="fas fa-eye"></i> [[%s|View]] ] ' .. | ||
'[ <i class="fas fa-edit"></i> [%s | '[ <i class="fas fa-edit"></i> [%s Edit] ] ' .. | ||
'[ <i class="fas fa-history"></i> [%s | '[ <i class="fas fa-history"></i> [%s History] ] ' .. | ||
'[ <i class="fas fa-sync-alt"></i> [%s | '[ <i class="fas fa-sync-alt"></i> [%s Purge] ]', | ||
docTitle.prefixedText, | docTitle.prefixedText, | ||
docTitle:fullUrl('action=edit'), | docTitle:fullUrl('action=edit'), | ||
| Line 36: | Line 30: | ||
)) | )) | ||
else | else | ||
links:wikitext(string.format( | links:wikitext(string.format( | ||
'[ <i class="fas fa-plus-circle" style="color:#d33;"></i> [%s | '[ <i class="fas fa-plus-circle" style="color:#d33;"></i> [%s Create documentation] ]', | ||
docTitle:fullUrl('action=edit&redlink=1') | docTitle:fullUrl('action=edit&redlink=1') | ||
)) | )) | ||
end | end | ||
local content = container:tag('div') | local content = container:tag('div') | ||
:addClass('template-documentation-content') | :addClass('template-documentation-content') | ||
if docTitle.exists then | if docTitle.exists then | ||
content:wikitext(frame:expandTemplate{ title = docTitle.prefixedText }) | content:wikitext(frame:expandTemplate{ title = docTitle.prefixedText }) | ||
else | else | ||
content:wikitext('<i class="fas fa-exclamation-circle" style="color:#d33;"></i> | 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 | end | ||
Latest revision as of 21:59, 15 May 2026
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