Module:Documentation: Difference between revisions

make all the helper functions available in the p table
(make a couple of the helper functions available for testing)
(make all the helper functions available in the p table)
Line 16:
----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------
 
Line 45 ⟶ 48:
end
 
p.message = message -- Make this function available for testing.
 
local function makeWikilink(page, display)
Line 54 ⟶ 57:
end
end
 
p.makeWikilink = makeWikilink
 
local function makeCategoryLink(cat, sort)
local catns = mw.site.namespaces[14].name
return makeWikilink(catns .. '/:' .. cat, sort)
end
 
p.makeCategoryLink = makeCategoryLink
 
local function makeUrlLink(url, display)
return mw.ustring.format('[%s %s]', url, display)
end
 
p.makeUrlLink = makeUrlLink
 
local function makeToolbar(...)
Line 76 ⟶ 85:
end
 
p.makeToolbar = makeToolbar -- Make this function available for testing.
 
local function err(msg)
Line 85 ⟶ 94:
)
end
 
p.err = err
 
----------------------------------------------------------------------------