Modul:Autocategories
Utseende
Moduldokumentasjon
[opprett]
-- module for replicating categories listed at Wikidata
-- © John Erling Blad, Creative Commons by Attribution 3.0
-- don't pollute with globals
require('Module:No globals')
-- @var our exposed table
local Autocategories = {}
-- find the P-ids from the argument lists
-- @param table vector forwarded from the method call
-- @return table hash of matching arguments
function Autocategories._findPids( pids, args )
for _,value in pairs( args ) do
local _,_,action,pid = string.find(value, '^%s*(!?)(P%d+)%s*$')
if pid then
pids[pid] = action == '' and true or nil
end
end
return pids
end
-- find the P-ids from the frame lists
-- @param table frames forwarded from the method call
-- @return table hash of matching arguments
function Autocategories.findPids( ... )
local pids = {}
for i = 1,arg.n do
local frame = arg[i]
pids = Autocategories._findPids( pids, frame.args )
return mw.dumpObject(pids)
end
do
return mw.dumpObject(pids)
end
local keys = {}
for key,_ in pairs( pids ) do
keys[1+#keys] = key
end
return mw.dumpObject(keys)
end
-- do all allowable categorizations
-- @param table frame arguments from invoke
-- @return string status report during development, should be an empty string
function Autocategories.run( frame )
--first call is when the call is encapsulated in a template
local pids = frame:getParent() and Autocategories.findPids( frame, frame:getParent() ) or Autocategories.findPids( frame )
--return table.concat( pids, ', ' )
return pids
end
-- export the accesspoint
return Autocategories