-- This module generates automatic documentation for .
local pronunciationData = mw.loadData('Module:IPAc-en/pronunciation')local phonemeData = mw.loadData('Module:IPAc-en/phonemes')local p =
local function makeCode(s) return string.format('%s
', mw.text.nowiki(s))end
local function buildTable(options) local ret = ret[#ret + 1] = '
' .. header end end if options.rows then for i, t in ipairs(options.rows) do ret[#ret + 1] = ' | -' for j, data in ipairs(t) do ret[#ret + 1] = ' | ' .. data end end end ret[#ret + 1] = ' |
---|
local function makeCodeTable(data, headers, callback) local headerRow = for i, header in ipairs(headers) do headerRow[#headerRow + 1] = header end local rows = for i, t in ipairs(data) do local aliases = if t.aliases then for i, alias in ipairs(t.aliases) do aliases[#aliases + 1] = makeCode(alias) end end aliases = table.concat(aliases, ', ') rows[#rows + 1] = end return buildTableend
function p.pronunciation return makeCodeTable(pronunciationData,, function (t) return t.text end)end
function p.phonemes return makeCodeTable(phonemeData, , function (t) return t.label, t.tooltip or , t.tooltip and 'diaphoneme' or 'separator' end )end
return p