Module:Documentation: Difference between revisions
No edit summary |
Fix section editing and generally retarded code. |
||
| Line 5: | Line 5: | ||
page = mw.title.getCurrentTitle() | page = mw.title.getCurrentTitle() | ||
namespace = args.type or page.nsText | namespace = args.type or page.nsText | ||
docPage = | docPage = args.page or namespace .. ':' .. page.baseText .. '/doc' | ||
local out | local out | ||
if page == docPage then | if page.fullText == docPage then | ||
out = f:preprocess( '{{subst:Template:Documentation/preload}}' ) | out = f:preprocess( '{{subst:Template:Documentation/preload}}' ) | ||
else | else | ||
| Line 33: | Line 33: | ||
end | end | ||
-- | -- Header on the documentation page | ||
function p.docPage( f ) | |||
local args = require( 'Module:ProcessArgs' ).norm() | |||
local badDoc = args.baddoc | |||
if f:callParserFunction( '#dplvar:noheader' ) == '1' then | |||
if badDoc then | |||
function p. | f:callParserFunction( '#dplvar:set', 'baddoc', '1' ) | ||
args = require( 'Module:ProcessArgs' ). | end | ||
return '' | |||
end | |||
local page = mw.title.getCurrentTitle() | |||
local namespace = args.type or page.nsText | |||
local pageType = 'template' | |||
if namespace == 'Module' then | if namespace == 'Module' then | ||
pageType = 'module' | pageType = 'module' | ||
| Line 55: | Line 57: | ||
end | end | ||
local colour = 'EAF4F9' | local colour = 'EAF4F9' | ||
local message = '' | local message = '' | ||
| Line 94: | Line 86: | ||
end | end | ||
-- | -- Wrapper around the documentation on the main page | ||
function p.page( f ) | function p.page( f ) | ||
docPage = mw.title.new( args.page or namespace .. ':' .. page.text .. '/doc' ) | local args = require( 'Module:ProcessArgs' ).norm() | ||
local page = mw.title.getCurrentTitle() | |||
local namespace = args.type or page.nsText | |||
local docPage = mw.title.new( args.page or namespace .. ':' .. page.text .. '/doc' ) | |||
local noDoc = args.nodoc or not docPage.exists | local noDoc = args.nodoc or not docPage.exists | ||
local badDoc = args.baddoc | local badDoc = args.baddoc | ||
local pageType = 'template' | |||
if namespace == 'Module' then | |||
pageType = 'module' | |||
elseif page.fullText:find( '.css$' ) then | |||
pageType = 'stylesheet' | |||
elseif page.fullText:find( '.js$' ) then | |||
pageType = 'script' | |||
elseif namespace == 'MediaWiki' then | |||
pageType = 'message' | |||
end | |||
local docText = '' | local docText = '' | ||
if not noDoc then | if not noDoc then | ||
f:callParserFunction( '#dplvar:set', 'noheader', '1' ) | |||
docText = mw.text.trim( f:expandTemplate{ title = ':' .. docPage.fullText } ) | |||
docText = mw.text.trim( f: | if f:callParserFunction( '#dplvar:baddoc' ) == '1' then | ||
badDoc = 1 | |||
end | |||
if docText == '' then | if docText == '' then | ||
noDoc = 1 | noDoc = 1 | ||
| Line 156: | Line 165: | ||
local out = { | local out = { | ||
'<div style="background-color:#' .. colour .. ';border:1px solid #AAA;padding:0.8em 1em 0. | '<div style="background-color:#' .. colour .. ';border:1px solid #AAA;padding:0.8em 1em 0.7em;clear:both">\n', | ||
'<div style="margin:-0.8em -1em 0.8em;padding: 0.8em 1em 0.7em;background-color:#EAF4F9;border-bottom:1px solid #AAA">\n', | '<div style="margin:-0.8em -1em 0.8em;padding: 0.8em 1em 0.7em;background-color:#EAF4F9;border-bottom:1px solid #AAA">\n', | ||
'<div style="float:right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n', | '<div style="float:right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n', | ||