Yu-Gi-Oh! Wiki
Yu-Gi-Oh! Wiki
No edit summary
Tag: sourceedit
No edit summary
Tag: sourceedit
Line 101: Line 101:
 
["related pages"] = "related pages",
 
["related pages"] = "related pages",
 
["hide video game decks"] = "hide video game decks"
 
["hide video game decks"] = "hide video game decks"
  +
}
  +
  +
problemCategory = {
  +
["character"] = '[['..'Category:Articles with outdated character infobox parameters]]'
 
}
 
}
   
Line 106: Line 110:
 
["character"] = character
 
["character"] = character
 
}
 
}
  +
   
   
Line 131: Line 136:
 
local list = deprecated[comparisonTable]
 
local list = deprecated[comparisonTable]
 
for k, v in pairs( args ) do
 
for k, v in pairs( args ) do
if list:in_list( k ) then
+
if type( list[k] ) == 'string' then
 
deprecation_count = deprecation_count + 1
 
deprecation_count = deprecation_count + 1
 
end
 
end
Line 142: Line 147:
 
type = 'style',
 
type = 'style',
 
issue = "'''Outdated {{"..template.."}} parameters''': ",
 
issue = "'''Outdated {{"..template.."}} parameters''': ",
fix = 'The following outdated parameters are used in {{'..template..'}} on this article and should be updated.'.._table(args, comparisonTable)
+
fix = 'The following outdated parameters are used in {{'..template..'}} on this article and should be updated.'.._table(args, comparisonTable)..problemCategory[comparisonTable]
 
}
 
}
 
}
 
}
Line 153: Line 158:
 
-- Internal functions (used in this and other Modules --
 
-- Internal functions (used in this and other Modules --
 
--------------------------------------------------------
 
--------------------------------------------------------
-- Deprecated parameter check
 
function character:in_list( parameter )
 
if type( self[parameter] ) == 'string' then
 
return true
 
else
 
return nil
 
end
 
end
 
 
-- Deprecated parameters replacement
 
function character:newparameter( parameter )
 
if self:in_list( parameter ) then
 
return self[parameter]
 
else
 
return nil
 
end
 
end
 
 
 
-- <table> of deprecated parameters
 
-- <table> of deprecated parameters
 
function _table(args, comparisonTable)
 
function _table(args, comparisonTable)
Line 189: Line 176:
 
end
 
end
 
wikitable:allDone()
 
wikitable:allDone()
return tostring(wikitable) .. '[[Category:Articles with outdated character infobox parameters]]'
+
return tostring(wikitable)
 
end
 
end
   

Revision as of 06:08, 9 July 2017

Test Template Info-Icon - Version (2) Module documentation

The documentation for this module is missing. Click here to create it.

local character = {
	["image name"] = "image",
	["image size"] = "width",
	["image caption"] = "caption",
	["english name"] = "en_name",
	["english manga name"] = "en_manga_name",
	["english anime name"] = "en_anime_name",
	["japanese name"] = "ja_name",
	["romaji name"] = "romaji_name",
	["asian english name"] = "asian english name",
	["nickname"] = "nicknames",
	["alternate name"] = "alternate name",
	["arabic name"] = "ar_name",
	["brazilian name"] = "pt_name",
	["filipino name"] = "fil_name",
	["french name"] = "fr_name",
	["german name"] = "de_name",
	["greek name"] = "el_name",
	["korean name"] = "ko_name",
	["italian name"] = "it_name",
	["portuguese name"] = "pt_name",
	["spanish name"] = "es_name",
	["manga debut"] = "manga_debut",
	["anime debut"] = "anime_debut",
	["video game debut"] = "video_game_debut",
	["appears manga"] = "appears_in_manga",
	["appears_manga"] = "appears_in_manga",
	["appears anime"] = "appears_in_anime",
	["appears_anime"] = "appears_in_anime",
	["appears books"] = "appears_in_books",
	["appears_books"] = "appears_in_books",
	["appears video games"] = "appears_in_video_games",
	["appears_video_games"] = "appears_in_video_games",
	["appears other"] = "appears_in_other",
	["appears_other"] = "appears_in_other",
	["blood type"] = "blood_type",
	["favorite food"] = "favorite_food",
	["favourite food"] = "favorite_food",
	["favourite_food"] = "favorite_food",
	["least favorite food"] = "least_favorite_food",
	["least favourite food"] = "least_favorite_food",
	["least_favourite_food"] = "least_favorite_food",
	["favorite sandwich"] = "favorite_food",
	["favorite_sandwich"] = "favorite_food",
	["favourite sandwich"] = "favorite_food",
	["favourite_sandwich"] = "favorite_food",
	["favorite sandwhich"] = "favorite_food",
	["favorite_sandwhich"] = "favorite_food",
	["favourite sandwhich"] = "favorite_food",
	["favourite_sandwhich"] = "favorite_food",
	["least favorite sandwich"] = "least_favorite_food",
	["least_favorite_sandwich"] = "least_favorite_food",
	["least favourite sandwich"] = "least_favorite_food",
	["least_favourite_sandwich"] = "least_favorite_food",
	["least favorite sandwhich"] = "least_favorite_food",
	["least_favorite_sandwhich"] = "least_favorite_food",
	["least favourite sandwhich"] = "least_favorite_food",
	["least_favourite_sandwhich"] = "least_favorite_food",
	["liked sandwiches"] = "favorite_food",
	["liked_sandwiches"] = "favorite_food",
	["liked sandwhiches"] = "favorite_food",
	["liked_sandwhiches"] = "favorite_food",
	["disliked sandwiches"] = "least_favorite_food",
	["disliked_sandwiches"] = "least_favorite_food",
	["disliked sandwhiches"] = "least_favorite_food",
	["disliked_sandwhiches"] = "least_favorite_food",
	["affiliation"] = "organization",
	["previous affiliation"] = "previous_organization",
	["previous partner"] = "previous partner",
	["previous_partner"] = "previous_partner",
	["previous team"] = "previous_team",
	["previous occupation"] = "previous_occupation",
	["manga deck"] = "manga_deck",
	["anime deck"] = "anime_deck",
	["ntrdeck"] = "ntr_deck",
	["gx02deck"] = "gx02_deck",
	["gx04deck"] = "gx04_deck",
	["gx06deck"] = "gx06_deck",
	["tf04deck"] = "tf04_deck",
	["wc4deckdesc"] = "wc4_deck",
	["wc6deck"] = "wc6_deck",
	["wc07deck"] = "wc07_deck",
	["wc08deck"] = "wc08_deck",
	["wc09deck"] = "wc09_deck",
	["wc10deck"] = "wc10_deck",
	["wc11deck"] = "wc11_deck",
	["ydt1deck"] = "ydt1_deck",
	["mddeck"] = "md_deck",
	["bamdeck"] = "bam_deck",
	["deck leader"] = "deck_leader",
	["deck master"] = "deck_master",
	["japanese voice"] = "ja_voice",
	["english voice"] = "en_voice",
	["arabic voice"] = "ar_voice",
	["french voice"] = "fr_voice",
	["german voice"] = "de_voice",
	["italian voice"] = "it_voice",
	["korean voice"] = "ko_voice",
	["portuguese voice"] = "pt_voice",
	["spanish voice"] = "es_voice",
	["related pages"] = "related pages",
	["hide video game decks"] = "hide video game decks"
}

problemCategory = {
    ["character"] = '[['..'Category:Articles with outdated character infobox parameters]]'
}

deprecated = {
	["character"] = character
}



----------------------------
-- Libraries of functions --
----------------------------
-- stands for High Frequency
-- local HF = require('Module:HF')
-- Parses invocation parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs

----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
-- Checks for deprecated parameters
-- use {{#invoke:Deprecated|check|deprecationTemplate = Infobox character|deprecationTable = character}}}} inside {{Infobox character}} to check against table "character" above
function deprecated.check(frame)
    local deprecation_count = 0
    local args = getArgs(frame, {
	    trim = true,
	    removeBlanks = true
    })
    local template = args.deprecationTemplate
    local comparisonTable = args.deprecationTable
    local list = deprecated[comparisonTable]
    for k, v in pairs( args ) do
        if type( list[k] ) == 'string' then
            deprecation_count = deprecation_count + 1
        end
    end
    if deprecation_count > 0 then
        return frame:expandTemplate{ 
        title = 'Ambox',
        args = { 
            class = 'sysop-show',
            type  = 'style',
            issue = "'''Outdated {{"..template.."}} parameters''': ",
            fix   = 'The following outdated parameters are used in {{'..template..'}} on this article and should be updated.'.._table(args, comparisonTable)..problemCategory[comparisonTable]
        }
    }
    else
        return null
    end
end

--------------------------------------------------------
-- Internal functions (used in this and other Modules --
--------------------------------------------------------
-- <table> of deprecated parameters
function _table(args, comparisonTable)
    local list = deprecated[comparisonTable]
    local wikitable = mw.html.create('table')
    :addClass('wikitable'):addClass('mw-collapsible')
    :tag('tr')
     :tag('th'):attr('scope', 'col'):wikitext('Outdated'):done()
     :tag('th'):attr('scope', 'col'):wikitext('New'):done()
    :done()
    for k, v in pairs( args ) do
        if type( list[k] ) == 'string' then
            wikitable:tag('tr')
            :tag('td'):tag('code'):wikitext(k):done():done()
            :tag('td'):tag('code'):wikitext(list[k]):done():done()
            :done()
        end
    end
    wikitable:allDone()
    return tostring(wikitable)
end

-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return deprecated