Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
m Replaced content with "-- <nowiki> local dependencyList = require( 'Module:DependencyList' ) local yn = require( 'Module:Yesno' ) local p = {} function p.doc( frame ) local title = mw.title..." Tag: Replaced |
No edit summary |
||
| Line 1: | Line 1: | ||
-- <nowiki> | -- <nowiki> | ||
local p = {} | local p = {} | ||
| Line 8: | Line 7: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local page = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' ) | local page = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' ) | ||
local ret, cats, ret1, ret2 | |||
local ret, cats, ret1, ret2 | |||
local onModule = title.namespace == 828 | local onModule = title.namespace == 828 | ||
| Line 20: | Line 18: | ||
:tag( 'td' ) | :tag( 'td' ) | ||
:css( 'width', '40px' ) | :css( 'width', '40px' ) | ||
:wikitext( '[[File: | :wikitext( '[[File:Template-info.png|35px|center|link=]]' ) | ||
:done() | :done() | ||
:tag( 'td' ) | :tag( 'td' ) | ||
| Line 39: | Line 37: | ||
:done() | :done() | ||
if title.namespace == 10 then | if title.namespace == 10 then | ||
cats = '[[Category:Template documentation|' .. title.baseText .. ']]' | cats = '[[Category:Template documentation|' .. title.baseText .. ']]' | ||
elseif title.namespace == 828 then | |||
elseif title.namespace == 828 then | |||
cats = '[[Category:Module documentation|' .. title.baseText .. ']]' | cats = '[[Category:Module documentation|' .. title.baseText .. ']]' | ||
else | else | ||
cats = '' | cats = '' | ||
end | end | ||
return tostring( ret ) | return tostring( ret ) .. cats | ||
end | end | ||
| Line 61: | Line 53: | ||
ret2 = mw.html.create( nil ) | ret2 = mw.html.create( nil ) | ||
:tag( 'div' ) | :tag('div') | ||
:addClass( ' | :addClass( 'doc-header' ) | ||
:tag( 'span' ) | |||
:addClass( 'doc-title' ) | |||
:wikitext( string.format('%s documentation', onModule and 'Module' or 'Template') ) | |||
:done() | |||
:tag( 'span' ) | :tag( 'span' ) | ||
:addClass( 'doc-editlinks' ) | |||
:addClass( 'plainlinks' ) | |||
:wikitext( | |||
'[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='edit'} ) ) .. ' edit]] ' .. | |||
'[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText, {action='purge'} ) ) .. ' purge]</span>]' | |||
) | |||
:done() | |||
:done() | :done() | ||
:tag( 'div' ) | :tag( 'div' ) | ||
:addClass( ' | :addClass( 'doc-transclusion' ) | ||
:wikitext( 'This documentation is transcluded from [[' .. page .. '/doc]].' ) | |||
:done() | :done() | ||
return ret1 .. tostring( ret2 ) | return ret1 .. tostring( ret2 ) | ||
end | end | ||
Revision as of 11:48, 20 February 2020
This documentation is transcluded from Module:Documentation/doc.
Implements Template:Documentation for templates and modules.
-- <nowiki>
local p = {}
function p.doc( frame )
local title = mw.title.getCurrentTitle()
local args = frame:getParent().args
local page = args[1] or mw.ustring.gsub( title.fullText, '/doc$', '' )
local ret, cats, ret1, ret2
local onModule = title.namespace == 828
-- subpage header
if title.subpageText == 'doc' then
ret = mw.html.create( 'table' )
:addClass( 'messagebox' )
:addClass( 'info' )
:tag( 'tr' )
:tag( 'td' )
:css( 'width', '40px' )
:wikitext( '[[File:Template-info.png|35px|center|link=]]' )
:done()
:tag( 'td' )
:tag( 'b' )
:wikitext( 'This is a documentation subpage for [[' .. page .. ']].' )
:done()
:tag( 'div' )
:css({ ['font-size'] = '0.85em', ['line-height'] = '1.4em' })
:wikitext(
string.format(
'It contains usage information, categories, and other content that is not part of the original %s page.',
onModule and 'module' or 'template'
)
)
:done()
:done()
:done()
:done()
if title.namespace == 10 then
cats = '[[Category:Template documentation|' .. title.baseText .. ']]'
elseif title.namespace == 828 then
cats = '[[Category:Module documentation|' .. title.baseText .. ']]'
else
cats = ''
end
return tostring( ret ) .. cats
end
-- template header
-- don't use mw.html as we aren't closing the main div tag
ret1 = '<div class="documentation">'
ret2 = mw.html.create( nil )
:tag('div')
:addClass( 'doc-header' )
:tag( 'span' )
:addClass( 'doc-title' )
:wikitext( string.format('%s documentation', onModule and 'Module' or 'Template') )
:done()
:tag( 'span' )
:addClass( 'doc-editlinks' )
:addClass( 'plainlinks' )
:wikitext(
'[[' .. tostring( mw.uri.fullUrl( page .. '/doc', {action='edit'} ) ) .. ' edit]] ' ..
'[<span class="jsPurgeLink">[' .. tostring( mw.uri.fullUrl( title.fullText, {action='purge'} ) ) .. ' purge]</span>]'
)
:done()
:done()
:tag( 'div' )
:addClass( 'doc-transclusion' )
:wikitext( 'This documentation is transcluded from [[' .. page .. '/doc]].' )
:done()
return ret1 .. tostring( ret2 )
end
return p
-- </nowiki>