Module:Find sources/autodoc

From Zoophilia Wiki
Revision as of 13:45, 26 September 2014 by meta>Mr. Stradivarius (write a function to get all page names with a certain prefix, to avoid making users manually add new template config pagenames and link config pagenames to some data module)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Documentation for this module may be created at Module:Find sources/autodoc/doc

local p = {}

function p.getPrefixPagenames(prefix)
	local specialText = string.format('{{Special:PrefixIndex/%s}}', prefix)
	specialText = mw.getCurrentFrame():preprocess(specialText)
	specialText = mw.text.unstrip(specialText)
	local pagenames = {}
	for s in string.gmatch(specialText, '<a href="[^"]*" title="([^"]*)"[^>]*>[^<]*</a>') do
		pagenames[#pagenames + 1] = mw.text.decode(s)
	end
	return pagenames
end

return p