Jump to content

Module:Exports: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Module to show exports of string modules
 
Wrap in <code>
Line 11: Line 11:
local moduleExports = require(currentTitle.fullText)
local moduleExports = require(currentTitle.fullText)
local keys = TableTools.keysToList(moduleExports)
local keys = TableTools.keysToList(moduleExports)
local outputKeys = {}
for i, v in ipairs(keys) do
return 'Exported types: ' .. mw.text.listToText(keys)
outputKeys[i] = '<code>' .. v .. '</code>'
end
return mw.text.listToText(outputKeys)
end
end



Revision as of 05:20, 24 August 2024

local p = {}
local TableTools = require('Module:TableTools')

function p.exports(frame)
	local currentTitle = mw.title.getCurrentTitle()
	
	if currentTitle.contentModel ~= 'Scribunto' then
		return ''
	end
	
	local moduleExports = require(currentTitle.fullText)
	local keys = TableTools.keysToList(moduleExports)
	local outputKeys = {}
	
	for i, v in ipairs(keys) do
		outputKeys[i] = '<code>' .. v .. '</code>'
	end
	
	return mw.text.listToText(outputKeys)
end

return p