REPORT: Modul:Asbox stubtree - Complete Analysis

Vikipediya, erkin ensiklopediya

Bu modul uchun Modul:Asbox stubtree/doc nomli hujjat sahifasini yaratishingiz mumkin

locali={}

functioni.exists(pagename)
localt=mw.title.new(pagename,"Template")
returnt.exists
end

functioni.pcase(word)
returnmw.ustring.upper(mw.ustring.sub(word,1,1))..mw.ustring.sub(word,2)
end

functioni._subtree(pagename)
localfinalresult
localout={"",pagename}
localtt
localtemppage
localtemppageexists
localr=0
localt={}
localremoveditem1=""
localremoveditem2=""

-- split items on dash into table
fortokeninmw.ustring.gmatch(pagename,"[^-]+")do
-- don't add numbered items to list
iftonumber(mw.ustring.sub(token,1,1))==nilthen
table.insert(t,token)
else
r=1
end
end
table.remove(t,#t)

while(#t>1)do
ifr==1then
r=0
else
-- Remove 1st item from list
removeditem1=t[1]
table.remove(t,1)
end

temppage=table.concat(t,"-").."-stub"
temppageexists=i.exists(temppage)
iftemppageexists==truethen
table.insert(out,"[[Template:"..temppage.."|"..i.pcase(temppage).."]]")
else
-- If template with first item does not exist, try removing last item
removeditem2=t[#t]
table.remove(t,#t)
temppage=removeditem1.."-"..table.concat(t,"-").."-stub"
if#t==0then
temppage=removeditem1.."-stub"
end
temppageexists=i.exists(temppage)
iftemppageexists==truethen
-- if exists then add first item back to list
table.insert(t,1,removeditem1)
table.insert(out,"[[Template:"..temppage.."|"..i.pcase(temppage).."]]")
else
-- if exists then add last item back to list
table.insert(t,removeditem2)
end
end
end

finalresult='<div style="float:right; border-style:dotted; border-width:2px; padding:5px; margin:5px;">'
finalresult=finalresult..'<span title="This shows the hierarchy of the stub template in relation to other templates." style="font-size:125%; font-weight:bold;">Stub iyerarxiyasi</span>'
finalresult=finalresult..table.concat(out,"\n* ")
finalresult=finalresult..'\n* [[Template:Stub|Stub]]'
finalresult=finalresult..'\n</div>'
returnfinalresult
end

functioni.subtree(frame)
returni._subtree(frame.args["pagename"])
end

returni