Module:ScriptItem: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(113 intermediate revisions by 3 users not shown)
Line 37: Line 37:
p.categoryWords = {
p.categoryWords = {
-- Category Names. (String(s) to look for in an item name, case-INsensitive.)
-- Category Names. (String(s) to look for in an item name, case-INsensitive.)
'Blip', 'Building', 'Camera', 'Chatbox', 'Civilian', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo',
'Blip', 'Building', 'Camera', 'Chatbox', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo',
'Element', 'Entity', 'Event', 'File', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'Network', 'Object',
'Element', 'Entity', 'Event', 'File', 'Font', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'NetFlags', 'Network', 'Object',
'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time', 'Transformable', 'Vehicle', 'Weather', 'World'
'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time', 'Vehicle', 'Weather', 'World'
}
}


Line 63: Line 63:
-- item page types
-- item page types
function p.showVariablePage(frame)
function p.showVariablePage(frame)
local parts = { "Description", "Value", "Settable" }
return p.showPage(frame, { "Value" })
return p.showPage(frame, parts)
end
end


function p.showFunctionPage(frame)
function p.showFunctionPage(frame)
local parts = { "Description", "Parameters", "Returns", "Callbacks" }
return p.showPage(frame, { "Parameters", "Return", "Callbacks" })
return p.showPage(frame, parts)
end
end


function p.showPropertyPage(frame)
function p.showPropertyPage(frame)
local parts = { "Description", "Value", "Settable", "Types", "Notes" }
return p.showPage(frame, { "Value" })
return p.showPage(frame, parts)
end
end


function p.showMethodPage(frame)
function p.showMethodPage(frame)
local parts = { "Description", "Parameters", "Returns", "Callbacks", "Types" }
return p.showPage(frame, { "Parameters", "Return", "Callbacks" })
return p.showPage(frame, parts)
end
end


function p.showEventPage(frame)
function p.showEventPage(frame)
local parts = { "Description", "Parameters", "Cancellable" }
return p.showPage(frame, { "Parameters", "Attributes" })
return p.showPage(frame, parts)
end
end


Line 90: Line 85:
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
Line 95: Line 94:
end
end
for i,part in ipairs(parts) do
for i,part in ipairs(parts) do
local data = p[part:lower()](frame)
local data = p[part:lower() == 'return' and 'returns' or part:lower()](frame)
if data and #data > 0 then
if data and #data > 0 then
if part == 'Settable' then
if part == 'Settable' then
Line 110: Line 109:
local lines = {}
local lines = {}
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}"))
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}"))
table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."<br>\n")
 
table.insert(lines, p.since(frame).."<br>\n")
    -- Added for discord embed styling
table.insert(lines, p.syntax(frame))
--table.insert(lines, "<meta content='"..p.getDisplayedName(frame).."' property='og:title' />"))
--table.insert(lines, "<meta content='"..p.description(frame).."' property='og:description' />"))
--table.insert(lines, "<meta content='#04C765' data-react-helmet='true' name='theme-color' />"))
 
table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."\n")
table.insert(lines, "<div style='margin-top: 20px;'>Available since "..p.since(frame).."</div>\n")
table.insert(lines, "<div style='margin-top: 6px;'>\n"..p.syntax(frame).."</div>\n")
table.insert(lines, "<div style='margin-top: 20px;'>\n"..p.description(frame).."</div>\n")
return lines
return lines
end
end
Line 122: Line 128:
if args.type == 'variable' or args.type == 'property' then
if args.type == 'variable' or args.type == 'property' then
table.insert(topBoxes, "settable")
table.insert(topBoxes, "settable")
elseif args.type == 'event' then
table.insert(topBoxes, "cancellable")
end
end
Line 128: Line 136:
table.insert(outBoxes, p[topBox.."Box"](frame))
table.insert(outBoxes, p[topBox.."Box"](frame))
end
end
return table.concat(outBoxes, ' ')
return table.concat(outBoxes, ' ').."<br>"
end
end


Line 274: Line 282:
local gamesText = p.getGames(args.games)
local gamesText = p.getGames(args.games)
if gamesText == "All Games" then
if gamesText == "All Games" then
return p.loadTemplate(frame, 'GreenInformationBox', {gamesText,id='games'});
return p.loadTemplate(frame, 'GreenInformationBox', {table.concat({
p.loadTemplate(frame, 'icon-iii'),
p.loadTemplate(frame, 'icon-vc'),
p.loadTemplate(frame, 'icon-sa'),
p.loadTemplate(frame, 'icon-iv')
}, ' '), id='games'})
else
else
return p.loadTemplate(frame, 'RedInformationBox', {gamesText..' Only',id='games'});
local games = { 'iii', 'vc', 'sa', 'iv' }
local out = {}
for i,game in ipairs(games) do
if gamesText:lower():find(game) then
table.insert(out, p.loadTemplate(frame, 'icon-'..game, {}))
end
end
return p.loadTemplate(frame, 'RedInformationBox', {table.concat(out, ' '), id='games'})
end
end
end
end
Line 282: Line 302:
function p.onlineBox(frame)
function p.onlineBox(frame)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
if args.sp == 'true' then
if args.sp == 'true' or args.online == 'false' then
return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'});
return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'});
elseif args.sp == 'false' or args.offline == 'false' then
return p.loadTemplate(frame, 'RedInformationBox', {'Online Only',id='online'});
else
else
return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'});
return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'});
Line 295: Line 317:
else
else
return p.loadTemplate(frame, 'GreenInformationBox', {'Read and Set',id='settable'});
return p.loadTemplate(frame, 'GreenInformationBox', {'Read and Set',id='settable'});
end
end
function p.cancellableBox(frame)
local args = p.getArgs(frame)
if p.isCancellable(frame)then
return p.loadTemplate(frame, 'GreenInformationBox', {'Cancellable',id='cancellable'});
else
return p.loadTemplate(frame, 'RedInformationBox', {'Not Cancellable',id='cancellable'});
end
end
end
end
Line 306: Line 337:
local endpointVersions = p.getEndpointVersions(args.since, args.endpoint)
local endpointVersions = p.getEndpointVersions(args.since, args.endpoint)
if #endpointVersions == 2 then
if #endpointVersions == 2 then
return "'''Server "..endpointVersions[1]..", Client "..endpointVersions[2].."'''"
return "'''Server "..endpointVersions[1].."''', '''Client "..endpointVersions[2].."'''"
else
else
if args.endpoint == 'server' then
if args.endpoint == 'server' then
Line 340: Line 371:
local entries = p.getIndexedArgs(frame, 'description')
local entries = p.getIndexedArgs(frame, 'description')
local startTextFirstLine = "The '''"..p.getDisplayedName(frame).."''' "..args.type.." is "..(args.type == "event" and "invoked when" or "used to").." "
local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedNameColoured(frame).."</span> [[HowTo/Functions|"..args.type.."]] is "..(args.type == "event" and "invoked when" or "used to").." "
for i,entry in ipairs(entries) do
for i,entry in ipairs(entries) do
Line 363: Line 394:
elseif entries[1] == "void" then
elseif entries[1] == "void" then
local headers = nil
local headers = nil
local rows = { { "void", "This "..args.type.." doesn't take any parameters." } }
local rows = { { p.formatType("void", frame), "This "..args.type.." doesn't take any parameters." } }
local widths = { 100, 400 }
local widths = { 120, 400 }
return p.table(headers, rows, widths, 'wikitable-parameters wikitable')
return p.table(headers, rows, widths, 'wikitable-returns wikitable')
else
else
for i,arg in ipairs(entries) do
for i,arg in ipairs(entries) do
Line 371: Line 402:
local isOptional = tokens[3] == 'optional'
local isOptional = tokens[3] == 'optional'
local defaultValue = isOptional and p.formatSource(tokens[4], frame) or "n/a"
local defaultValue = isOptional and "<span style='font-family: \"Source Code Pro\", monospace;'>"..tokens[4].."</span>" or "n/a"
local description = p.formatDescription(table.concat(tokens, ' ', isOptional and 5 or 3))
local description = p.formatDescription(table.concat(tokens, ' ', isOptional and 5 or 3))
if isEvent then
if isEvent then
rows[i] = { i..") ", p.formatType(tokens[1], frame), p.formatSource(tokens[2], frame), description }
rows[i] = { (i + 1)..") ", p.formatType(tokens[1], frame), p.formatName(tokens[2], frame), description }
else
else
rows[i] = { i..") ", p.formatType(tokens[1], frame), p.formatSource(tokens[2], frame), (isOptional and ("Optional, defaults to "..defaultValue..". ") or "")..description }
rows[i] = { i..") ", p.formatType(tokens[1], frame), p.formatName(tokens[2], frame), (isOptional and ("Optional, defaults to "..defaultValue..". ") or "")..description }
end
end
end
end
Line 383: Line 414:
if isEvent then
if isEvent then
table.insert(rows, 1, { "1) ", p.formatType("Event", frame), "event", "The event object for this event." })
table.insert(rows, 1, { "1) ", p.formatType("Event", frame), p.formatName("event", frame), "The event object for this event." })
end
end
Line 389: Line 420:
if isEvent then
if isEvent then
headers = nil--{ "Type", "Name", "Description" }
headers = nil--{ "Type", "Name", "Description" }
widths = { 50, 200, 100, 400 }
widths = { 30, 80, 110, 400 }
else
else
headers = nil--{ "Type", "Name", "Presence", "Default Value", "Description" }
headers = nil--{ "Type", "Name", "Presence", "Default Value", "Description" }
widths = { 50, 200, 100, 400 }
widths = { 30, 80, 110, 400 }
end
end
return p.table(headers, rows, widths, 'wikitable-parameters wikitable')
return p.table(headers, rows, widths, 'wikitable-parameters wikitable')
Line 404: Line 435:
local headers
local headers
local widths
local widths
local isVoidReturn = false
rows = {}
rows = {}
entries = p.getIndexedArgs(frame, 'return')
entries = p.getIndexedArgs(frame, 'return')
text = text.."'''Success Returns'''\n\n"
if #entries == 0 then
if #entries == 0 then
text = text..p.documentationMissing(frame, "Success returns").."<br><br>"
text = text..p.documentationMissing(frame, "Returns").."<br><br>"
else
else
for i,arg in ipairs(entries) do
for i,arg in ipairs(entries) do
Line 419: Line 450:
local description
local description
if type:lower() == "void" then
if type:lower() == "void" then
description = "This "..args.type.." doesn't return any values on success."
isVoidReturn = true
description = "This "..args.type.." doesn't return a value."
elseif tokens[2] then
elseif tokens[2] then
description = p.formatDescription(table.concat(tokens, ' ', 2))
description = p.formatDescription(table.concat(tokens, ' ', 2))
else
else
description = p.documentationMissing(frame, "Description for success return value")
description = p.documentationMissing(frame, "Description for return value")
end
end
rows[i] = { p.formatType(tokens[1], frame), description }
rows[i] = { p.formatType(tokens[1], frame), description }
end
end
headers = { "Type", "Description" }
headers = nil-- { "Type", "Description" }
widths = { 100, 400 }
widths = { 120, 400 }
text = text..p.table(headers, rows, widths, 'wikitable-returns wikitable')
text = text..p.table(headers, rows, widths, 'wikitable-returns wikitable')
end
end
rows = {}
--[[
entries = p.getIndexedArgs(frame, 'returnFail')
-- commented out as failure returns are not currently implemented in GTAC.
text = text.."'''Failure Returns'''\n\n"
if not isVoidReturn then
if #entries == 0 then
rows = {}
text = text..p.documentationMissing(frame, "Failure returns")
entries = p.getIndexedArgs(frame, 'returnFail')
else
text = text.."'''Failure Return:'''\n\n"
for i,arg in ipairs(entries) do
if #entries == 0 then
local tokens = p.split(arg, ' ')
text = text..p.documentationMissing(frame, "Failure returns")
else
local type = tokens[1]
for i,arg in ipairs(entries) do
type = p.standardizeNullType(type)
local tokens = p.split(arg, ' ')
local value
local type = tokens[1]
if type:lower() == 'void' then
type = p.standardizeNullType(type)
value = "n/a"
elseif tokens[2] then
local value
value = p.formatSource(table.concat(tokens, ' ', 2), frame)
if type:lower() == 'void' then
else
value = "n/a"
value = p.formatSource(p.documentationMissing(frame, "Description for failure return value"), frame)
elseif tokens[2] then
value = p.formatSource(table.concat(tokens, ' ', 2), frame)
else
value = p.formatSource(p.documentationMissing(frame, "Description for failure return value"), frame)
end
rows[i] = { p.formatType(tokens[1], frame), value }
end
end
headers = nil--{ "Type", "Value" }
rows[i] = { p.formatType(tokens[1], frame), value }
widths = { 120, 400 }
text = text..p.table(headers, rows, widths, 'wikitable-returns wikitable')
end
end
headers = { "Type", "Value" }
widths = { 100, 400 }
text = text..p.table(headers, rows, widths, 'wikitable-returns wikitable')
end
end
]]
return text
return text
Line 509: Line 546:
local description = p.formatDescription(table.concat(callbackTokens, ' ', 3))
local description = p.formatDescription(table.concat(callbackTokens, ' ', 3))
rows[i2] = { p.formatType(parameterType, frame), p.formatSource(parameterName, frame), description }
rows[i2] = { i2..') ', p.formatType(parameterType, frame), p.formatName(parameterName, frame), description }
end
end
local headers, widths
local headers, widths
headers = { "Type", "Name", "Description" }
headers = nil--{ "Type", "Name", "Description" }
widths = { 100, 180, 400 }
widths = { 30, 80, 110, 400 }
local table2 = "\n"..p.table(headers, rows, widths, 'wikitable-callback wikitable')
local table2 = "\n"..p.table(headers, rows, widths, 'wikitable-callback wikitable')
table.insert(html, table2)
table.insert(html, table2)
Line 539: Line 576:
end
end


function p.cancellable(frame)
function p.attributes(frame)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
local headers = nil--{ "Type", "Description" }
local rows = {}
if p.isCancellable(frame) then
if p.isCancellable(frame) then
return "This "..args.type.." can be cancelled using [[event.preventDefault|event.preventDefault]]."
rows[1] = { 'cancellable', 'This '..args.type..' can be cancelled, by using [[event.preventDefault|event.preventDefault]].' }
else
else
return "This "..args.type.." can't be cancelled."
rows[1] = { p.formatType('const', frame), 'This '..args.type..' cannot be cancelled.' }
end
end
local widths = { 120, 400 }
return p.table(headers, rows, widths, 'wikitable-returns wikitable')
end
end


Line 560: Line 600:
local description = p.formatDescription(table.concat(tokens, ' ', 2))
local description = p.formatDescription(table.concat(tokens, ' ', 2))
local headers = { "Type", "Description" }
local headers = nil--{ "Type", "Description" }
local rows = { { p.formatType(tokens[1], frame), description } }
local rows = {}
local widths = { 100, 400 }
rows[1] = { p.formatType(tokens[1], frame), description }
return p.table(headers, rows, widths, 'wikitable-parameters wikitable')
if args.readonly == 'true' then
rows[2] = { p.formatType('readonly', frame), 'This '..args.type..' cannot be changed.' }
else
rows[2] = { 'read/set', 'This '..args.type..' can be changed, as well as read.' }
end
local widths = { 120, 400 }
return p.table(headers, rows, widths, 'wikitable-returns wikitable')
end
end


Line 578: Line 624:
function p.types(frame)
function p.types(frame)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
return p.getDerivedClassesText(frame, args.class)
return p.getTypesText(frame, args.class)
end
 
function p.symbols(frame)
local args = p.getArgs(frame)
return p.getSymbolsText(frame, args.class)
end
end


Line 760: Line 811:
local args = p.getArgs(frame)
local args = p.getArgs(frame)
if p.isOOP(frame) then
if p.isOOP(frame) then
return args.class:lower().."."..args.name
return p.lowerFirstCharCase(args.class).."."..args.name
else
else
return args.name
return args.name
end
end
function p.getTypeRgb()
return '#009106'
end
function p.getNameRgb()
return '#0645ad'
end
function p.getDisplayedNameColoured(frame)
local typeRgb = p.getTypeRgb()
local nameRgb = p.getNameRgb()
local args = p.getArgs(frame)
if p.isOOP(frame) then
return "<span style='color:"..typeRgb..";'>"..p.lowerFirstCharCase(args.class).."</span>.<span style='color:"..nameRgb.."';>"..args.name.."</span>"
else
return "<span style='color:"..nameRgb.."';>"..args.name.."</span>"
end
end
end
end
Line 805: Line 875:
end
end


function p.getDerivedClassesText(frame, baseType)
function p.getTypesText(frame, baseType)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
local derivedTypes = {
local derivedTypes = {
ped     = {'Civilian', 'Player'},
ped     = {'Player'},
physical = {'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
physical = {'Object', 'Ped', 'Vehicle', 'Player'},
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'},
transformable = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
element = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'},
element = {'Transformable', 'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'}
vehicle = {'Train'},
event = {'CancellableEvent', 'KeyEvent'},
surface = {'RenderTarget', 'Texture'}
}
}
local baseTypeLower = baseType:lower()
local serverTypes = {}
local sharedTypes = {
'Building', 'Client', 'Effect', 'Event', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4',
'Element', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle', 'Train', 'XmlDocument', 'XmlElement',
'CancellableEvent', 'KeyEvent', 'Marker', 'Object', 'Ped', 'Player'
}
local out = {}
local getTypeSide = function(type)
for i2,type2 in ipairs(serverTypes) do
if type:lower() == type2:lower() then
return 'server'
end
end
for i2,type2 in ipairs(sharedTypes) do
if type:lower() == type2:lower() then
return 'shared'
end
end
return 'client'
end
if derivedTypes[baseTypeLower] then
if baseType then
local types = p.copyTable(derivedTypes[baseTypeLower])
local baseTypeLower = baseType:lower()
table.insert(types, baseType)
local allTypes
for i,type in ipairs(types) do
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
types[i] = type
end
end
p.sortTable(types)
p.sortTable(types)
return "This "..args.type.." can be used on types: "..p.formatSource(table.concat(types, " "), frame)
for i,type in ipairs(types) do
else
types[i] = p.loadTemplate(frame, 'Side', {[getTypeSide(type)]='1'}).." ".."<span style=\"font-family: 'Source Code Pro', monospace;\">"..type.."</span>"
return "This "..args.type.." can only be used on type: "..p.formatType(baseType, frame)
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
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[1]..' is a '..p.properCase(args.type)..', which exists in the global namespace.' or parts[#parts]..' is a '..p.properCase(args.type)..', which exists in the '..parts[#parts-1]..' namespace.'
elseif args.type == 'method' or args.type == 'property' then
local parts = p.split(p.getDisplayedName(frame), ".")
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>")
local headers = { 'Symbol Name', 'Symbol Type', 'Container', 'Description' }
table.insert(out, "\n"..p.table(headers, 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
table.insert(out, "<br>"..line)
end
end
end
return table.concat(out, "")
end
end


Line 837: Line 1,014:


function p.formatType(type, frame)
function p.formatType(type, frame)
return p.formatSource(type, frame)
return "<span style='font-family: \"Source Code Pro\", monospace; color: "..p.getTypeRgb()..";\"'>"..type.."</span>"
end
 
function p.formatName(name, frame)
return "<span style='font-family: \"Source Code Pro\", monospace; color: "..p.getNameRgb()..";\"'>"..name.."</span>"
end
end


function p.formatSource(type, frame)
function p.formatSource(type, frame)
return frame:preprocess('<source>'..type..'</source>')
return frame:preprocess('<syntaxhighlight>'..type..'</syntaxhighlight>')
end
end


Line 975: Line 1,156:
function p.properCase(text)
function p.properCase(text)
return text:sub(1,1):upper()..text:sub(2):lower()
return text:sub(1,1):upper()..text:sub(2):lower()
end
function p.lowerFirstCharCase(text)
return text:sub(1,1):lower()..text:sub(2)
end
end


2,591

edits