Movatterモバイル変換


[0]ホーム

URL:


Jump to content
Wikiversity
Search

Module:Asbox stubtree

From Wikiversity

This module is used byModule:Asbox to create stub hierarchy boxes for stub template documentations. It also implements {{asbox/stubtree}} and served the same function via {{Asbox/templatepage}} prior to beingconverted to Lua.



locali={}functioni.exists(pagename)localt=mw.title.new(pagename,"Template")returnt.existsendfunctioni.pcase(word)returnmw.ustring.upper(mw.ustring.sub(word,1,1))..mw.ustring.sub(word,2)endfunctioni._subtree(pagename)localfinalresultlocalout={"",pagename}localttlocaltemppagelocaltemppageexistslocalr=0localt={}localremoveditem1=""localremoveditem2=""-- split items on dash into tablefortokeninmw.ustring.gmatch(pagename,"[^-]+")do-- don't add numbered items to listiftonumber(mw.ustring.sub(token,1,1))==nilthentable.insert(t,token)elser=1endendtable.remove(t,#t)while(#t>1)doifr==1thenr=0else-- Remove 1st item from listremoveditem1=t[1]table.remove(t,1)endtemppage=table.concat(t,"-").."-stub"temppageexists=i.exists(temppage)iftemppageexists==truethentable.insert(out,"[[Template:"..temppage.."|"..i.pcase(temppage).."]]")else-- If template with first item does not exist, try removing last itemremoveditem2=t[#t]table.remove(t,#t)temppage=removeditem1.."-"..table.concat(t,"-").."-stub"if#t==0thentemppage=removeditem1.."-stub"endtemppageexists=i.exists(temppage)iftemppageexists==truethen-- if exists then add first item back to listtable.insert(t,1,removeditem1)table.insert(out,"[[Template:"..temppage.."|"..i.pcase(temppage).."]]")else-- if exists then add last item back to listtable.insert(t,removeditem2)endendendfinalresult='<div>'finalresult=finalresult..'<span title="This shows the hierarchy of the stub template in relation to other templates.">Stub hierarchy</span>'finalresult=finalresult..table.concat(out,"\n* ")finalresult=finalresult..'\n* [[Template:Stub|Stub]]'finalresult=finalresult..'\n</div>'returnfinalresultendfunctioni.subtree(frame)returni._subtree(frame.args["pagename"])endreturni
Retrieved from "https://en.wikiversity.org/w/index.php?title=Module:Asbox_stubtree&oldid=2663079"

[8]ページ先頭

©2009-2025 Movatter.jp