Group dependencies > 5
starcitizen>Alistair3149 Немає опису редагування |
starcitizen>Alistair3149 (Group dependencies > 5) |
||
| Рядок 6: | Рядок 6: | ||
local param = require( 'Module:Paramtest' ) | local param = require( 'Module:Paramtest' ) | ||
local dpl = require( 'Module:DPLlua' ) | local dpl = require( 'Module:DPLlua' ) | ||
local moduleIsUsed = false | local moduleIsUsed = false | ||
local COLLAPSE_LIST_LENGTH_THRESHOLD = 5 | |||
local MAX_DYNAMIC_REQUIRE_LIST_LENGTH = 30 | local MAX_DYNAMIC_REQUIRE_LIST_LENGTH = 30 | ||
local dynamicRequireListQueryCache = {} | local dynamicRequireListQueryCache = {} | ||
| Рядок 295: | Рядок 294: | ||
end | end | ||
local function collapseList( list, id, listType ) | |||
local text = string.format( '%d %s', #list, listType ) | |||
local button = '<span>' .. text .. ':</span>' | |||
list = enum.map( list, function(x) return '\n# '..x end ) | |||
local content = '\n'..table.concat( list )..'\n\n' | |||
return { tostring( button ) .. tostring( content ) } | |||
end | |||
--- Creates a link to [[Special:Search]] showing all pages found by getDynamicRequireList() in case it found more than MAX_DYNAMIC_REQUIRE_LIST_LENGTH pages. | --- Creates a link to [[Special:Search]] showing all pages found by getDynamicRequireList() in case it found more than MAX_DYNAMIC_REQUIRE_LIST_LENGTH pages. | ||
| Рядок 382: | Рядок 381: | ||
local res = {} | local res = {} | ||
if #invokedByList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
table.insert( res, string.format( | table.insert( res, string.format( | ||
"<div role='note' class='hatnote'><div class=hatnote-container navigation-not-searchable'><span class='hatnote-icon metadata'>[[File:WikimediaUI-Code.svg|14px|link=]]</span>'''%s''' is invoked by %s.</div></div>", | "<div role='note' class='hatnote'><div class=hatnote-container navigation-not-searchable'><span class='hatnote-icon metadata'>[[File:WikimediaUI-Code.svg|14px|link=]]</span>'''%s''' is invoked by %s.</div></div>", | ||
moduleName, | moduleName, | ||
collapseList( invokedByList, 'invokedBy', 'templates' )[1] | |||
) ) | ) ) | ||
else | |||
for _, item in ipairs( invokedByList ) do | |||
table.insert( res, string.format( | |||
"<div role='note' class='hatnote'><div class=hatnote-container navigation-not-searchable'><span class='hatnote-icon metadata'>[[File:WikimediaUI-Code.svg|14px|link=]]</span>'''%s''' is invoked by %s.</div></div>", | |||
moduleName, | |||
item | |||
) ) | |||
end | |||
end | end | ||
if #templateData > 0 then | if #templateData > 0 then | ||
| Рядок 440: | Рядок 439: | ||
end | end | ||
if #requiredByList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
requiredByList = collapseList( requiredByList, 'requiredBy', 'modules' ) | |||
end | |||
if #loadedByList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
loadedByList = collapseList( loadedByList, 'loadedBy', 'modules' ) | |||
end | |||
local res = {} | local res = {} | ||
| Рядок 480: | Рядок 479: | ||
local res = {} | local res = {} | ||
if #requireList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
requireList = collapseList( requireList, 'require', 'modules' ) | |||
end | |||
for _, requiredModuleName in ipairs( requireList ) do | for _, requiredModuleName in ipairs( requireList ) do | ||
| Рядок 502: | Рядок 501: | ||
local res = {} | local res = {} | ||
if #loadDataList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
loadDataList = collapseList( loadDataList, 'loadData', 'modules' ) | |||
end | |||
for _, loadedModuleName in ipairs( loadDataList ) do | for _, loadedModuleName in ipairs( loadDataList ) do | ||
| Рядок 524: | Рядок 523: | ||
local res = {} | local res = {} | ||
if #usedTemplateList > COLLAPSE_LIST_LENGTH_THRESHOLD then | |||
usedTemplateList = collapseList( usedTemplateList, 'usedTemplates', 'templates' ) | |||
end | |||
for _, templateName in ipairs( usedTemplateList ) do | for _, templateName in ipairs( usedTemplateList ) do | ||
| Рядок 549: | Рядок 548: | ||
for _, item in ipairs( styleList ) do | for _, item in ipairs( styleList ) do | ||
table.insert( res, string.format( | table.insert( res, string.format( | ||
"<div role='note' class='hatnote'><div class=hatnote-container navigation-not-searchable'><span class='hatnote-icon metadata'>[[File:WikimediaUI-Code.svg|14px|link=]]</span>'''%s''' | "<div role='note' class='hatnote'><div class=hatnote-container navigation-not-searchable'><span class='hatnote-icon metadata'>[[File:WikimediaUI-Code.svg|14px|link=]]</span>'''%s''' invokes [[%s]] using [[Star Citizen:TemplateStyles|TemplateStyles]].</div></div>", | ||
templateName, | templateName, | ||
item.styleName | item.styleName | ||