模組:Complex Number/Calculate/doc.lua
外观

![]() | 本模块使用以下模板样式: |
本模組用於生成Module:Complex_Number/Calculate系列模組與模板之說明文件。
模組內容
脚本错误:函数“usageDoc”不存在。
運算符
語法 | 名稱 | 元數 | 說明 | 優先 | 範例 | 效果 | math輸出
第7行Lua错误:attempt to call global 'getArgs' (a nil value) |
---|
- 註:另有
>=
、<=
、==
(相等判斷)、~=
(不相等判斷)、!=
(不相等判斷)、@=
(數值指派)、+=
(相加指派)、-=
(相減指派)、*=
(相乘指派)、/=
(相除指派)、^=
(冪指派)、&=
(邏輯與指派)、|=
(邏輯或指派)可供使用,其會自動替換為上表中對應的運算元。指派運算元須注意等號左邊必須是一個單一變數詞語,不可以是括弧或函數變換的結果。
常數和數值
語法 | 名稱 | 別名 | 說明 | 數值 | math輸出
脚本错误:函数“constantDoc”不存在。 |
---|
函數
語法 | 名稱 | 參數 數量 |
說明 | 範例 | 效果 | math輸出
脚本错误:函数“functionDoc”不存在。 |
---|
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