6,834
edits
No edit summary |
No edit summary |
||
Line 90: | Line 90: | ||
function p.showPage(frame, parts) | function p.showPage(frame, parts) | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
if args.type ~= 'event' then | |||
table.insert(parts, "Types") | |||
end | |||
table.insert(parts, "Symbols") | |||
local lines = p.getPageTopLines(frame) | local lines = p.getPageTopLines(frame) | ||
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do | for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do | ||
table.insert(parts, part) | table.insert(parts, part) | ||
Line 616: | Line 619: | ||
end | end | ||
function p. | function p.types(frame) | ||
local args = p.getArgs(frame) | |||
return p.getTypesText(frame, args.class) | |||
end | |||
function p.symbols(frame) | |||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
return p. | return p.getSymbolsText(frame, args.class) | ||
end | end | ||
Line 864: | Line 872: | ||
end | end | ||
function p. | function p.getTypesText(frame, baseType) | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
Line 882: | Line 890: | ||
'Element', 'Transformable', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle' | 'Element', 'Transformable', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle' | ||
} | } | ||
local getTypeSide = function(type) | local getTypeSide = function(type) | ||
Line 911: | Line 907: | ||
end | end | ||
if | if baseType then | ||
local baseTypeLower = baseType:lower() | |||
local allTypes | |||
if derivedTypes[baseTypeLower] then | |||
allTypes = p.copyTable(derivedTypes[baseTypeLower]) | |||
table.insert(allTypes, 1, baseType) | |||
else | |||
allTypes = { baseType } | |||
end | |||
local types = {} | |||
for i,type in ipairs(allTypes) do | |||
types[i] = type | |||
end | |||
p.sortTable(types) | |||
for i,type in ipairs(types) do | |||
types[i] = p.loadTemplate(frame, 'Side', {[getTypeSide(type)]='1'}).." ".."<span style=\"font-family: 'Source Code Pro', monospace;\">"..type.."</span>" | |||
end | |||
--table.insert(out, "<div style='margin-top: 20px;'></div>") | |||
table.insert(out, "\n"..table.concat(types, "<br>")) | |||
end | |||
return table.concat(out, "") | |||
end | |||
function p.getSymbolsText(frame, baseType) | |||
local args = p.getArgs(frame) | |||
local out = {} | |||
local rows = {} | |||
if args.type == 'function' or args.type == 'variable' then | |||
local parts = p.split(p.getDisplayedName(frame), ".") | |||
for i=1,(#parts)-1,1 do | |||
rows[i] = {} | |||
rows[i][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[i].."</span>" | |||
rows[i][2] = 'Namespace' | |||
rows[i][3] = i == 1 and 'Global' or 'Namespace: '..parts[i-1] | |||
rows[i][4] = i == 1 and parts[i]..' is a namespace, which exists in the global namespace.' or parts[i]..' is a namespace, which exists in the '..parts[i-1]..' namespace.' | |||
end | end | ||
rows[#parts] = {} | |||
rows[#parts][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[#parts].."</span>" | |||
rows[#parts][2] = p.properCase(args.type) | |||
rows[#parts][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1] | |||
rows[#parts][4] = #parts == 1 and parts[#parts]..' is a '..p.properCase(args.type)..', which exists in the global namespace.' or parts[i]..' is a '..p.properCase(args.type)..', which exists in the '..parts[#parts-1]..' namespace.' | |||
elseif args.type == 'method' or args.type == 'property' then | |||
rows[1] = {} | |||
rows[1][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[1].."</span>" | |||
rows[1][2] = 'Object' | |||
rows[1][3] = 'n/a' | |||
rows[1][4] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[1].."</span>"..' is an object.' | |||
rows[2] = {} | |||
rows[2][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[2].."</span>" | |||
rows[2][2] = p.properCase(args.type) | |||
rows[2][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1] | |||
rows[2][4] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..parts[2].."</span>"..' is a '..p.properCase(args.type)..', which is used on objects of type '..parts[1] | |||
elseif args.type == 'event' then | |||
rows[1] = {} | |||
rows[1][1] = "<span style=\"font-family: 'Source Code Pro', monospace; color: "..p.getNameRgb()..";\">"..p.getDisplayedName(frame).."</span>" | |||
rows[1][2] = 'String' | |||
rows[1][3] = 'n/a' | |||
rows[1][4] = 'Events are referenced by name. Event names use data type String.' | |||
end | |||
--table.insert(out, "<div style='margin-top: 20px;'></div>") | |||
table.insert(out, "\n"..p.table(false, rows, { 120, 120, 400 }, false)) | |||
if args.type ~= 'event' then | |||
local languages = { 'JS', 'Lua', 'Squirrel' } | |||
local languageSymbols = { | |||
['JS'] = { ['function'] = 'dot', ['variable'] = 'dot', ['method'] = 'dot', ['property'] = 'dot' }, | |||
['Lua'] = { ['function'] = 'dot', ['variable'] = 'dot', ['method'] = 'colon', ['property'] = 'dot' }, | |||
['Squirrel'] = { ['function'] = 'dot', ['variable'] = 'dot', ['method'] = 'dot', ['property'] = 'dot' } | |||
} | |||
for i,language in ipairs(languages) do | |||
local line | |||
if args.type == 'function' then | |||
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to call a function.' | |||
elseif args.type == 'variable' then | |||
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a variable.' | |||
elseif args.type == 'method' then | |||
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to call a method.' | |||
elseif args.type == 'property' then | |||
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a property.' | |||
end | end | ||
table.insert(out, "\n"..line) | |||
end | end | ||
end | end |
edits