Module:Documentation: Difference between revisions

add comments to p.addTrackingCategories and reduce line length a little
m>Mr. Stradivarius
(allow protection templates to display in the module namespace)
m>Mr. Stradivarius
(add comments to p.addTrackingCategories and reduce line length a little)
Line 893: Line 893:


function p.addTrackingCategories(env)
function p.addTrackingCategories(env)
--[[
-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
-- @env - environment table containing title objects, etc., generated with p.getEnvironment
-- Messages:
-- 'display-strange-usage-category' --> true
-- 'doc-subpage' --> 'doc'
-- 'testcases-subpage' --> 'testcases'
-- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'
-- 'strange-usage-category-mainspace-sort' --> 'Main:'
--]]
local title = env.title
local title = env.title
local ret = ''
local ret = ''
local subpage = title.subpageText
local subpage = title.subpageText
if message('display-strange-usage-category', nil, 'boolean') and (subpage == message('doc-subpage') or subpage == message('testcases-subpage')) then
if message('display-strange-usage-category', nil, 'boolean')
local sort = (title.namespace == 0 and message('strange-usage-category-mainspace-sort') or '') .. title.prefixedText -- Sort on namespace.
and (subpage == message('doc-subpage') or subpage == message('testcases-subpage'))
then
-- Generate the strange usage category link. This category is sorted by namespace.
local sort = (title.namespace == 0 and message('strange-usage-category-mainspace-sort') or '')
.. title.prefixedText
ret = ret .. makeCategoryLink(message('strange-usage-category'), sort)
ret = ret .. makeCategoryLink(message('strange-usage-category'), sort)
end
end
Anonymous user