Module:Asbox stubtree
Appearance
![]() | This module is rated as ready 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 by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 39,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
This module is used by Module: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 being converted to Lua.
Acknowledgements
In addition to the contributors listed in the contribution histories of Template:Asbox stubtree and Module:Asbox stubtree, this module also implements ideas from the deleted Template:Asbox/templatepage, which primary authors are User:MSGJ and User:WOSlinker.
local i = {}
function i.exists(pagename)
return 1
end
function i._subtree(pagename)
local out = {"",pagename}
local tt
local temppage
local temppageexists
local r = 0
local t = {}
-- split items on dash into table
for token in mw.ustring.gmatch(pagename, "[^-]+") do
-- don't add numbered items to list
if tonumber(mw.ustring.sub(token,1,1)) == nil then
table.insert(t,token)
r = 1
end
end
table.remove(t, #t)
while (#t > 1) do
if r == 1 then
r = 0
else
table.remove(t, 1)
temppage = table.concat(t, "-") .. "-stub"
temppageexists = i.exists(temppage)
if temppageexists == 0 then
--TODO
end
end
table.insert(out,temppage)
end
return table.concat(out, "\n* ")
end
function i.subtree(frame)
return i._subtree(frame.args["pagename"])
end
return i