Module:Documentation: Difference between revisions

Preserve spacing
oh right, named args are always trimmed...
Line 18: Line 18:
-- Creating a documentation page or transclution through {{subst:doc}}
-- Creating a documentation page or transclution through {{subst:doc}}
function p.create( f )
function p.create( f )
local args = f:getParent().args
local args = require( 'Module:ProcessArgs' ).norm()
local page = mw.title.getCurrentTitle()
local page = mw.title.getCurrentTitle()
local docPage = args.page or page.nsText .. ':' .. page.baseText .. '/doc'
local docPage = args.page or page.nsText .. ':' .. page.baseText .. '/doc'
Line 30: Line 30:
local val = args[key]
local val = args[key]
if val then
if val then
if key == 'content' then val = '\n' .. val .. '\n' end
table.insert( templateArgs, key .. '=' .. val )
table.insert( templateArgs, key .. '=' .. val )
end
end
Line 35: Line 36:
out = '{{documentation|' .. table.concat( templateArgs, '|' ) .. '}}'
out = '{{documentation|' .. table.concat( templateArgs, '|' ) .. '}}'
out = out:gsub( '|}}', '}}' )
if not args.content then
if not args.content then
out = '\n<!-- Put categories/interwiki on the documentation page -->'
out = out .. '\n<!-- Put categories/interwiki on the documentation page -->'
end
end
out = out:gsub( '|}}', '}}' )
end
end