Module:IPAc-en/documentation

Documentation for this module may be created at Module:IPAc-en/documentation/doc

Documentation for this module may be created at Module:IPAc-en/documentation/doc

-- This module generates automatic documentation for [[Template:IPAc-en]].

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('<code>%s</code>', mw.text.nowiki(s))
end

local function buildTable(options)
	local ret = {}
	ret[#ret + 1] = '{| class="wikitable"'
	if options.headerRow then
		for i, header in ipairs(options.headerRow) do
			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] = '|}'
	return table.concat(ret, '\n')
end

local function makeCodeTable(data, headers, callback)
	local headerRow = {'Code', 'Aliases'}
	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] = {makeCode(t.code), aliases, callback(t)}
	end
	return buildTable{
		headerRow = headerRow,
		rows = rows
	}
end

function p.pronunciation()
	return makeCodeTable(pronunciationData, {'Output'}, function (t)
		return t.text
	end)
end

function p.phonemes()
	return makeCodeTable(
		phonemeData,
		{'Display text', 'Tooltip', 'Type'},
		function (t)
			return t.label, t.tooltip or '', t.tooltip and 'diaphoneme' or 'separator'
		end
	)
end

return p


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.