mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
docs/API.md is 18.7k lines and its anchors are signature slugs, so editing a signature breaks the 281 internal and 88 README links into it. Blizzard solved the same problem by shipping the API as data plus a browser addon, and warcraft.wiki.gg renders those same tables. One set of descriptors can feed all three. Each registration now carries one next to it: typed arguments and returns, nilability, defaults, and a sentence. Events, enumerations and returned table shapes are described the same way. No Script_* body changed. Game.h gains namespace Game::Doc (Field with Req/Opt/Vararg, FieldList, Function, Method, Structure, Event) and a trailing descriptor argument on all six Game::Lua::Register* plus Event::Custom::AutoReserve. api/Documentation.cpp records every registration on the first pass of each Lua state and seals it, so /reload re-registers but records nothing and the environment comes from which pass saw the name. Export is lazy: nothing is materialized until C_APIDocumentation.GetSystem asks for one system, because eager export would build thousands of tables per reload for a slash command. _classicapi_UndocumentedAPI lists what still has no descriptor. AddOns/!!!ClassicAPI/APIDocumentation/ ports Blizzard_APIDocumentation's eight files. Named /classicapi, not /api: the browser holds only what ClassicAPI adds, so /api would have implied the whole 1.12 surface. Two deliberate differences from the retail source, both noted in the file headers: a system search also matches its namespace, since that is the name people type; and an undocumented function says so, because an empty signature otherwise reads as a real one. LinkUtil gains the SetItemRef to LinkUtil.ProcessLink dispatch. That handler registry was dead code; a new link type now registers a handler instead of stacking another SetItemRef override. Also defines assertsafe there, which was undefined and only mattered once the function went live. Documented: the C_Spell and C_SpellBook surface, the spell globals, both spellbook enumerations, the 13 UNIT_SPELLCAST_* events, GameTooltip as the widget-method example and C_Glue as the glue and mixed-environment example. 66 of 692 function registrations. tools/New-ApiDocSkeletons.ps1 emits paste-ready skeletons to make the rest of the sweep tractable. Verified in game: the browser lists, searches, and prints detail; links render and click through; right-click copies and shift-click dumps.
122 lines
3.7 KiB
Lua
122 lines
3.7 KiB
Lua
-- Backport of Blizzard_APIDocumentation/FunctionsAPIMixin.lua to vanilla 1.12
|
|
-- / Lua 5.0.
|
|
--
|
|
-- Implementation differences from the retail source: none.
|
|
--
|
|
-- A widget-method system (Type "ScriptObject") carries no Namespace, so
|
|
-- GetFullName prints its methods bare -- "SetSpellByID(spellID)" -- exactly as
|
|
-- retail prints its own widget API.
|
|
|
|
FunctionsAPIMixin = CreateFromMixins(BaseAPIMixin);
|
|
|
|
function FunctionsAPIMixin:GetParentName()
|
|
if self.System then
|
|
return self.System:GetName();
|
|
end
|
|
|
|
return "";
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetType()
|
|
return "function";
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetLinkHexColor()
|
|
return "55ddff";
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetFullName(decorateOptionals, includeColorCodes)
|
|
if self.System and self.System:GetNamespaceName() ~= "" then
|
|
return ("%s.%s(%s)"):format(self.System:GetNamespaceName(), self:GetName(), self:GetArgumentString(decorateOptionals, includeColorCodes));
|
|
end
|
|
return ("%s(%s)"):format(self:GetName(), self:GetArgumentString(decorateOptionals, includeColorCodes));
|
|
end
|
|
|
|
function FunctionsAPIMixin:MatchesSearchString(searchString)
|
|
if self:GetLoweredName():match(searchString) then
|
|
return true;
|
|
end
|
|
|
|
if self:MatchesAnyDocumentation(searchString) then
|
|
return true;
|
|
end
|
|
|
|
if self:MatchesAnyAPI(self.Arguments, searchString) then
|
|
return true
|
|
end
|
|
|
|
if self:MatchesAnyAPI(self.Returns, searchString) then
|
|
return true
|
|
end
|
|
|
|
return false;
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetArgumentString(decorateOptionals, includeColorCodes)
|
|
if self.Arguments then
|
|
local values = {};
|
|
for i, argumentInfo in ipairs(self.Arguments) do
|
|
if includeColorCodes ~= false then
|
|
table.insert(values, ("%s|cff%s"):format(argumentInfo:GetArgumentString(decorateOptionals, includeColorCodes), self:GetLinkHexColor()));
|
|
else
|
|
table.insert(values, argumentInfo:GetArgumentString(decorateOptionals, includeColorCodes));
|
|
end
|
|
end
|
|
return table.concat(values, ", ");
|
|
end
|
|
return "";
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetReturnString(decorateOptionals, includeColorCodes)
|
|
if self.Returns then
|
|
local values = {};
|
|
for i, returnInfo in ipairs(self.Returns) do
|
|
if includeColorCodes ~= false then
|
|
table.insert(values, ("%s|cff%s"):format(returnInfo:GetReturnString(decorateOptionals, includeColorCodes), self:GetLinkHexColor()));
|
|
else
|
|
table.insert(values, returnInfo:GetReturnString(decorateOptionals, includeColorCodes));
|
|
end
|
|
end
|
|
return table.concat(values, ", ");
|
|
end
|
|
return "";
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetClipboardString()
|
|
if self.Returns then
|
|
return ("local %s = %s"):format(self:GetReturnString(false, false), self:GetFullName(false, false));
|
|
end
|
|
return self:GetFullName(false, false);
|
|
end
|
|
|
|
function FunctionsAPIMixin:GetDetailedOutputLines()
|
|
local lines = {};
|
|
table.insert(lines, self:GetSingleOutputLine());
|
|
|
|
self:AddSystemTag(lines);
|
|
self:AddDocumentationTags(lines);
|
|
|
|
if self.Arguments then
|
|
table.insert(lines, APIDocumentation:GetIndentString() .. "Arguments");
|
|
for i, argumentInfo in ipairs(self.Arguments) do
|
|
if argumentInfo:GetStrideIndex() == 1 then
|
|
table.insert(lines, APIDocumentation:GetIndentString(2) .. "(Variable arguments)");
|
|
end
|
|
|
|
table.insert(lines, APIDocumentation:GetIndentString(2) .. ("%d. %s"):format(i, argumentInfo:GetSingleOutputLine()));
|
|
end
|
|
end
|
|
|
|
if self.Returns then
|
|
table.insert(lines, APIDocumentation:GetIndentString() .. "Returns");
|
|
for i, returnInfo in ipairs(self.Returns) do
|
|
if returnInfo:GetStrideIndex() == 1 then
|
|
table.insert(lines, APIDocumentation:GetIndentString(2) .. "(Variable returns)");
|
|
end
|
|
table.insert(lines, APIDocumentation:GetIndentString(2) .. ("%d. %s"):format(i, returnInfo:GetSingleOutputLine()));
|
|
end
|
|
end
|
|
|
|
return lines;
|
|
end
|