Module:DependencyList: Difference between revisions

m Undo revision 8888 by Banri (talk)
Tag: Undo
mNo edit summary
 
Line 247: Line 247:
---@param addCategories boolean
---@param addCategories boolean
---@return string
---@return string
local function messageBoxUnused( pageName, addCategories )
    local html = mw.html.create( 'table' ):addClass( 'messagebox obsolete plainlinks' )
    html:tag( 'td' )
        :attr( 'width', '40xp' )
        :wikitext( '[[File:Carter.png|center|30px|link=]]' )
    :done()
    :tag( 'td' )
        :wikitext( "'''This module is unused.'''" )
        :tag( 'div' )
            :css{ ['font-size']='0.85em', ['line-height']='1.45em' }
            :wikitext( string.format( 'This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add <code>{{[[Template:Documentation|Documentation]]}}</code>/<code>{{[[Template:No documentation|No&nbsp;documentation]]}}</code> to the calling template\'s or parent\'s module documentation.', pageName ) )
            :wikitext( addCategories and '[[Category:Unused modules]]' or '' )
        :done()
    :done()
    return tostring( html )
end
local function collapseList( list, id, listType )
local function collapseList( list, id, listType )
     local text = string.format( '%d %s', #list, listType )
     local text = string.format( '%d %s', #list, listType )
Line 537: Line 519:
     addCategories = yn( param.default_to( addCategories, title.subpageText~='doc' ) )
     addCategories = yn( param.default_to( addCategories, title.subpageText~='doc' ) )
     moduleIsUsed = yn( param.default_to( isUsed, false ) )
     moduleIsUsed = yn( param.default_to( isUsed, false ) )
   
    if title.text:match( '^(.-)/' ) == 'Sandbox' then
    moduleIsUsed = true -- Don't show sandbox modules as unused
    end


     if currentPageName:find( '^Template:' ) or currentPageName:find( '^Calculator:' ) then
     if currentPageName:find( '^Template:' ) or currentPageName:find( '^Calculator:' ) then
Line 599: Line 577:
     table.insert( res, formatUsedTemplatesList( currentPageName, addCategories, usedTemplateList ) )
     table.insert( res, formatUsedTemplatesList( currentPageName, addCategories, usedTemplateList ) )
     table.insert( res, formatRequiredByList( currentPageName, addCategories, whatModulesLinkHere ) )
     table.insert( res, formatRequiredByList( currentPageName, addCategories, whatModulesLinkHere ) )
    if not moduleIsUsed then
        table.insert( res, 1, messageBoxUnused( currentPageName:gsub( 'Module:', '' ), addCategories ) )
    end


     return table.concat( res )
     return table.concat( res )