跳转到内容

模組:Complex Number/Calculate/doc.lua

本页使用了标题或全文手工转换
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2022年3月26日 (六) 05:07 建立内容为“local p={} local lib_calc = require('Module:Complex_Number/Calculate') function p.operatorDoc(frame) if frame == mw.getCurrentFrame() then -- We're being called via #invoke. The args are passed through to the module -- from the template page, so use the args that were passed into the template. args = getArgs(frame, { trim = false, removeBlanks = false }) --frame.args else -- We're being c…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

local p={}
local lib_calc = require('Module:Complex_Number/Calculate')
function p.operatorDoc(frame)
	if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = getArgs(frame, {
        	trim = false,
			removeBlanks = false
        }) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
	end
	local ret = ''
	for k,v in pairs(lib_calc.symbol_table)do
		if not v.private then
			--public operator
			if v.name then
				ret = ret .. (ret==''and''or'\n') .. '|-'
				ret = ret .. '<code><nowiki>' .. k .. '</nowiki></code>' .. ' || '
				ret = ret .. "[[" .. v.name .. '|' .. v.title .. "]]" .. ' || '
				ret = ret .. v.description .. ' || '
				ret = ret .. '<code><nowiki>' .. v.example .. '</nowiki></code>' .. ' || '
				local math_output = ''
				xpcall(function() 
					math_output = lib_calc.calculate({v.example,class='cmath'})
					math_output = frame:extensionTag{ name = 'math', content = tostring(math_output)}
				end,function()return''end)
				ret = ret .. tostring(math_output) .. ' || '
				math_output = ''
				if not v.example:find('%%') then xpcall(function() 
					math_output = lib_calc.calculate({v.example,class='mathtag'})
				end,function()return''end)end
				ret = ret .. tostring(math_output)
			end
		end
	end
	return ret
end
return p