Interface administrators, moderator
2,601
edits
No edit summary |
No edit summary |
||
(64 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 | 'Blip', 'Building', 'Camera', 'Chatbox', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo', | ||
'Element', 'Entity', 'Event', 'File', 'Font', '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 | '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) | ||
return p.showPage(frame, { "Value" }) | |||
return p.showPage(frame, | |||
end | end | ||
function p.showFunctionPage(frame) | function p.showFunctionPage(frame) | ||
return p.showPage(frame, { "Parameters", "Return", "Callbacks" }) | |||
end | end | ||
function p.showPropertyPage(frame) | function p.showPropertyPage(frame) | ||
return p.showPage(frame, { "Value" }) | |||
return p.showPage(frame, | |||
end | end | ||
function p.showMethodPage(frame) | function p.showMethodPage(frame) | ||
return p.showPage(frame, { "Parameters", "Return", "Callbacks" }) | |||
end | end | ||
function p.showEventPage(frame) | function p.showEventPage(frame) | ||
return p.showPage(frame, { "Parameters", "Attributes" }) | |||
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 | ||
table.insert(parts, part) | table.insert(parts, part) | ||
Line 111: | Line 109: | ||
local lines = {} | local lines = {} | ||
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}")) | table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}")) | ||
-- Added for discord embed styling | |||
--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, "__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: 20px;'>Available since "..p.since(frame).."</div>\n") | ||
table.insert(lines, "<div style='margin-top: 6px;'>"..p.syntax(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;'>"..p.description(frame).."</div>\n") | table.insert(lines, "<div style='margin-top: 20px;'>\n"..p.description(frame).."</div>\n") | ||
return lines | return lines | ||
end | end | ||
Line 124: | 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 276: | 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', { | 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', { | 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 284: | 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 297: | 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 342: | Line 371: | ||
local entries = p.getIndexedArgs(frame, 'description') | local entries = p.getIndexedArgs(frame, 'description') | ||
local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p. | 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 365: | 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 = { | local widths = { 120, 400 } | ||
return p.table(headers, rows, widths, '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 377: | Line 406: | ||
if isEvent then | if isEvent then | ||
rows[i] = { i..") ", p.formatType(tokens[1], frame), p. | 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. | 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 385: | 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 411: | Line 440: | ||
entries = p.getIndexedArgs(frame, 'return') | entries = p.getIndexedArgs(frame, 'return') | ||
if #entries == 0 then | if #entries == 0 then | ||
text = text..p.documentationMissing(frame, " | 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 422: | Line 451: | ||
if type:lower() == "void" then | if type:lower() == "void" then | ||
isVoidReturn = true | isVoidReturn = true | ||
description = "This "..args.type.." doesn't return | 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 | description = p.documentationMissing(frame, "Description for return value") | ||
end | end | ||
rows[i] = { | rows[i] = { p.formatType(tokens[1], frame), description } | ||
end | end | ||
headers = nil-- { "Type", "Description" } | headers = nil-- { "Type", "Description" } | ||
widths = { | 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 | ||
Line 460: | Line 489: | ||
end | end | ||
rows[i] = { | rows[i] = { p.formatType(tokens[1], frame), value } | ||
end | end | ||
headers = nil--{ "Type", "Value" } | headers = nil--{ "Type", "Value" } | ||
widths = { | 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 | ||
Line 517: | Line 546: | ||
local description = p.formatDescription(table.concat(callbackTokens, ' ', 3)) | local description = p.formatDescription(table.concat(callbackTokens, ' ', 3)) | ||
rows[i2] = { i2..') ', p.formatType(parameterType, frame), p. | rows[i2] = { i2..') ', p.formatType(parameterType, frame), p.formatName(parameterName, frame), description } | ||
end | end | ||
Line 547: | Line 576: | ||
end | end | ||
function p. | 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 | ||
rows[1] = { 'cancellable', 'This '..args.type..' can be cancelled, by using [[event.preventDefault|event.preventDefault]].' } | |||
else | else | ||
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 569: | Line 601: | ||
local headers = nil--{ "Type", "Description" } | local headers = nil--{ "Type", "Description" } | ||
local rows = { { | local rows = {} | ||
local widths = { | rows[1] = { p.formatType(tokens[1], frame), description } | ||
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') | return p.table(headers, rows, widths, 'wikitable-returns wikitable') | ||
end | end | ||
Line 584: | Line 622: | ||
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 768: | 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 | 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 813: | Line 875: | ||
end | end | ||
function p. | function p.getTypesText(frame, baseType) | ||
local args = p.getArgs(frame) | local args = p.getArgs(frame) | ||
local derivedTypes = { | local derivedTypes = { | ||
ped = { | ped = {'Player'}, | ||
physical = {'Object', 'Ped', 'Vehicle | physical = {'Object', 'Ped', 'Vehicle', 'Player'}, | ||
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle | entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'}, | ||
element = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'}, | |||
vehicle = {'Train'}, | |||
event = {'CancellableEvent', 'KeyEvent'}, | |||
surface = {'RenderTarget', 'Texture'} | |||
} | } | ||
local serverTypes = { | local serverTypes = {} | ||
local sharedTypes = { | local sharedTypes = { | ||
'Client', 'Effect', 'Event | 'Building', 'Client', 'Effect', 'Event', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4', | ||
'Element | 'Element', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle', 'Train', 'XmlDocument', 'XmlElement', | ||
'CancellableEvent', 'KeyEvent', 'Marker', 'Object', 'Ped', 'Player' | |||
} | } | ||
local out = {} | local out = {} | ||
local getTypeSide = function(type) | local getTypeSide = function(type) | ||
Line 860: | Line 913: | ||
end | end | ||
if | if baseType then | ||
local baseTypeLower = baseType:lower() | local baseTypeLower = baseType:lower() | ||
local allTypes | local allTypes | ||
Line 877: | Line 930: | ||
types[i] = p.loadTemplate(frame, 'Side', {[getTypeSide(type)]='1'}).." ".."<span style=\"font-family: 'Source Code Pro', monospace;\">"..type.."</span>" | types[i] = p.loadTemplate(frame, 'Side', {[getTypeSide(type)]='1'}).." ".."<span style=\"font-family: 'Source Code Pro', monospace;\">"..type.."</span>" | ||
end | end | ||
table.insert(out, "<div style='margin-top: 20px;'></div>") | --table.insert(out, "<div style='margin-top: 20px;'></div>") | ||
table.insert(out, "\n''' | 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 | end | ||
table.insert(out, "<br>"..line) | |||
table.insert(out, " | |||
end | end | ||
end | end | ||
Line 906: | Line 1,014: | ||
function p.formatType(type, frame) | function p.formatType(type, frame) | ||
return p. | 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('< | return frame:preprocess('<syntaxhighlight>'..type..'</syntaxhighlight>') | ||
end | end | ||
Line 1,044: | 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 | ||