Module:Documentation: Difference between revisions
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- Customizable strings | |||
local i18n = { | local i18n = { | ||
-- default settings, change when necessary | -- default settings, change when necessary | ||
| Line 73: | Line 72: | ||
} | } | ||
-- Customizable functions | |||
local function pageCategoryHandler( category ) | |||
return f:expandTemplate{ title = 'translation category', args = { category, project = '0' } } | |||
end | |||
-- Load modules | |||
local static = require( 'Module:Static' ) | |||
-- Internal functions | |||
local function loadStyles( stylesheet ) | local function loadStyles( stylesheet ) | ||
if not stylesheet or mw.text.trim( stylesheet ) == '' then | if not stylesheet or mw.text.trim( stylesheet ) == '' then | ||
| Line 82: | Line 90: | ||
local function getType( namespace, page ) | local function getType( namespace, page ) | ||
local pageType = 'template' | local pageType = 'template' | ||
if namespace == 'Module' then | if namespace == 'Module' then | ||
pageType = 'module' | pageType = 'module' | ||
| Line 94: | Line 101: | ||
pageType = 'message' | pageType = 'message' | ||
end | end | ||
return pageType | return pageType | ||
end | end | ||
| Line 102: | Line 108: | ||
end | end | ||
-- Creating a documentation page or transclusion through {{subst:docc}} | -- Exported functions | ||
function p.create( f ) -- Creating a documentation page or transclusion through {{subst:docc}} | |||
local args = require( 'Module:ProcessArgs' ).norm() | local args = require( 'Module:ProcessArgs' ).norm() | ||
local page = mw.title.getCurrentTitle() | local page = mw.title.getCurrentTitle() | ||
| Line 137: | Line 143: | ||
end | end | ||
-- Header on the documentation page | function p.docPage( f ) -- Header on the documentation page | ||
local args = require( 'Module:ProcessArgs' ).merge( true ) | local args = require( 'Module:ProcessArgs' ).merge( true ) | ||
local badDoc = args.baddoc | local badDoc = args.baddoc | ||
| Line 183: | Line 188: | ||
end | end | ||
-- Wrapper around the documentation on the main page | function p.page( f ) -- Wrapper around the documentation on the main page | ||
-- mw.text.trim uses mw.ustring.gsub, which silently fails on large strings | -- mw.text.trim uses mw.ustring.gsub, which silently fails on large strings | ||
local function trim( s ) | local function trim( s ) | ||
| Line 305: | Line 309: | ||
if category then | if category then | ||
body:wikitext( | body:wikitext( pageCategoryHander( category ) ) | ||
end | end | ||