Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Asbox stubtree

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Ready for useThis module is rated asready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved bysandbox testing rather than repeated trial-and-error editing.
ProtectedThis module issubject to page protection. It is ahighly visible module in use by a very large number of pages, or issubstituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it isprotected from editing.
WarningThis Lua module is used onapproximately 39,000 pages and changes may be widely noticed. Test changes in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. Consider discussing changes on thetalk page before implementing them.

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.

Acknowledgements

In addition to the contributors listed in the contribution histories ofTemplate:Asbox stubtree andModule:Asbox stubtree, this module also implements ideas from thedeleted Template:Asbox/templatepage, which primary authors areUser:MSGJ andUser:WOSlinker.

The abovedocumentation istranscluded fromModule:Asbox stubtree/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

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.wikipedia.org/w/index.php?title=Module:Asbox_stubtree&oldid=577704600"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp