├── .gitignore ├── LICENSE.md ├── README.md ├── wow-api-docs.lua ├── wow-api-docs.sublime-project └── wow-api-docs.toc /.gitignore: -------------------------------------------------------------------------------- 1 | ## Sublime 2 | *.sublime-workspace -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Gethe. All rights reserved. 2 | 3 | Permission is granted for anyone to use, read, or otherwise interpret this 4 | software for any purpose, without any restrictions. 5 | 6 | Permission is granted for anyone to modify this software or reuse portions 7 | of it for private use only. 8 | 9 | Permission is granted for anyone to aggregate this software with other works 10 | not derived from this software for the purpose of creating a user interface 11 | replacement (commonly referred to as a "compilation" or "addon pack") for the 12 | "World of Warcraft" game client, and to distribute such collective works on 13 | websites operated by Curse Inc or Good Game Mods, LLC (including curse.com, 14 | curseforge.com, wowace.com and wowinterface.com) as long as the software is 15 | not modified in any way, including by modifying or removing any files. 16 | 17 | This software may not be redistributed by itself or in any other way, in whole 18 | or in part, modified or unmodified, without specific prior written permission 19 | from the author of this software. 20 | 21 | The names of this software and/or its author may not be used to promote or 22 | endorse works derived from this software without specific prior written 23 | permission from the author of this software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 29 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WoW API Docs 2 | ============ 3 | 4 | An in-game graphical browser for [Blizzard's API Documentation](https://github.com/Gethe/wow-ui-source/tree/ptr/AddOns/Blizzard_APIDocumentation) 5 | 6 | Once installed, type `/api gui` to open. 7 | 8 | 9 | ## To Do ## 10 | * Cross linking fields - When a field refers to another field, make it a clickable link that takes you to that field. 11 | * Search - Allow for searching from within the GUI with clickable links in the results. 12 | -------------------------------------------------------------------------------- /wow-api-docs.lua: -------------------------------------------------------------------------------- 1 | local ADDON_NAME = ... 2 | 3 | -- Lua Globals -- 4 | local next = _G.next 5 | 6 | -- Libs -- 7 | local ACR = _G.LibStub("AceConfigRegistry-3.0") 8 | local ACD = _G.LibStub("AceConfigDialog-3.0") 9 | 10 | local app = "WoWAPIDocs" 11 | local apiTable = { 12 | name = ADDON_NAME, 13 | type = "group", 14 | args = {} 15 | } 16 | do -- generate ace config table 17 | local fieldFormat = "%s: %s" 18 | local function CreateItemGroup(itemGroup) 19 | local itemArgs = {} 20 | if itemGroup then 21 | for index, field in next, itemGroup do 22 | _G.print(index, field:GetName(), field:GetFullName()) 23 | local outputString = field:GetLuaType() 24 | if field:IsOptional() then 25 | if field.Default ~= nil then 26 | outputString = outputString .. (" (default:%s)"):format(_G.tostring(field.Default)); 27 | else 28 | outputString = outputString .. " (optional)"; 29 | end 30 | end 31 | if field.Documentation then 32 | outputString = ("%s - %s"):format(outputString, _G.table.concat(field.Documentation, " ")); 33 | end 34 | itemArgs[field:GetLoweredName()] = { 35 | name = fieldFormat:format(field:GenerateAPILink(), outputString), 36 | type = "description", 37 | order = index 38 | } 39 | --[[local strideIndex = field:GetStrideIndex() 40 | local docString 41 | if field.Documentation then 42 | docString = _G.table.concat(field.Documentation, " ") 43 | end 44 | itemArgs[field:GetLoweredName()] = { 45 | name = field:GetName(), 46 | type = "group", 47 | args = { 48 | documentation = { 49 | name = "documentation: " .. (docString or ""), 50 | type = "description", 51 | hidden = not docString, 52 | order = 1, 53 | }, 54 | default = { 55 | name = "default: " .. _G.tostring(field.Default), 56 | type = "description", 57 | hidden = field.Default ~= nil, 58 | order = 1, 59 | }, 60 | luaType = { 61 | name = "luaType: " .. _G.tostring(field:GetLuaType()), 62 | type = "description", 63 | order = 1, 64 | }, 65 | strideIndex = { 66 | name = "strideIndex: " .. (strideIndex or ""), 67 | type = "description", 68 | hidden = not strideIndex, 69 | order = 2, 70 | }, 71 | isOptional = { 72 | name = "isOptional: " .. _G.tostring(field:IsOptional()), 73 | type = "description", 74 | order = 3, 75 | }, 76 | output = { 77 | name = "output: " .. field:GetSingleOutputLine(), 78 | type = "description", 79 | order = 4, 80 | }, 81 | }, 82 | }]] 83 | end 84 | end 85 | return itemArgs 86 | end 87 | 88 | local function CreateAPIGroup(apiType, apiGroup) 89 | local groupArgs = {} 90 | for index, item in next, apiGroup do 91 | _G.print(index, item:GetName(), item:GetFullName()) 92 | groupArgs[item:GetLoweredName()] = { 93 | name = item:GetName(), 94 | type = "group", 95 | args = { 96 | header = { 97 | name = item:GetFullName(true, false), 98 | type = "header", 99 | order = 0 100 | }, 101 | doc = { 102 | name = function() 103 | if item.Documentation then 104 | return _G.table.concat(item.Documentation, " ") 105 | else 106 | return "" 107 | end 108 | end, 109 | type = "description", 110 | hidden = not item.Documentation, 111 | order = 1 112 | }, 113 | arguments = { 114 | name = "Arguments", 115 | type = "group", 116 | inline = true, 117 | hidden = not item.Arguments, 118 | order = 2, 119 | args = CreateItemGroup(item.Arguments) 120 | }, 121 | returns = { 122 | name = "Returns", 123 | type = "group", 124 | inline = true, 125 | hidden = not item.Returns, 126 | order = 3, 127 | args = CreateItemGroup(item.Returns) 128 | }, 129 | fields = { 130 | name = "Fields", 131 | type = "group", 132 | inline = true, 133 | hidden = not item.Fields, 134 | order = 4, 135 | args = CreateItemGroup(item.Fields) 136 | }, 137 | }, 138 | } 139 | end 140 | return groupArgs 141 | end 142 | 143 | for index, system in next, _G.APIDocumentation.systems do 144 | _G.print(index, system:GetName(), system:GetFullName()) 145 | apiTable.args[system:GetLoweredName()] = { 146 | name = system:GetName(), 147 | type = "group", 148 | args = { 149 | functions = { 150 | name = "Functions", 151 | type = "group", 152 | hidden = not system.Functions or #system.Functions == 0, 153 | args = CreateAPIGroup("Functions", system.Functions) 154 | }, 155 | tables = { 156 | name = "Tables", 157 | type = "group", 158 | hidden = not system.Tables or #system.Tables == 0, 159 | args = CreateAPIGroup("Tables", system.Tables) 160 | } 161 | }, 162 | } 163 | end 164 | 165 | 166 | do -- Explicitly add SharedTypes since they don't have a system 167 | local name = "SharedTypes" 168 | local table = { 169 | _G.APIDocumentation.tables[1], 170 | _G.APIDocumentation.tables[2], 171 | _G.APIDocumentation.tables[3], 172 | _G.APIDocumentation.tables[4] 173 | } 174 | apiTable.args[name:lower()] = { 175 | name = name, 176 | type = "group", 177 | args = { 178 | tables = { 179 | name = "Tables", 180 | type = "group", 181 | args = CreateAPIGroup("Tables", table) 182 | } 183 | } 184 | } 185 | end 186 | ACR:RegisterOptionsTable(app, apiTable) 187 | ACD:SetDefaultSize(app, 800, 600) 188 | end 189 | 190 | local function OpenDocs(section, ...) 191 | _G.print("Open Docs", section, ...) 192 | if ACD.OpenFrames[app] and not section then 193 | ACD:Close(app) 194 | elseif section then 195 | ACD:SelectGroup(app, section, ...) 196 | else 197 | ACD:Open(app) 198 | end 199 | end 200 | local function ShowSystem(system) 201 | _G.print("Show system", system) 202 | for k, v in next, system do 203 | _G.print(k, v) 204 | end 205 | OpenDocs(system:GetLoweredName()) 206 | end 207 | local function ShowSearch(matches) 208 | _G.print("Show search", matches) 209 | for k, v in next, matches do 210 | _G.print(k, v) 211 | end 212 | OpenDocs() 213 | end 214 | 215 | local API_HandleSlash = _G.APIDocumentation.HandleSlashCommand 216 | function _G.APIDocumentation:HandleSlashCommand(command) 217 | _G.print("HandleSlashCommand", command) 218 | local commands = { (" "):split(command) }; 219 | 220 | if commands[1] == "gui" or ACD.OpenFrames[app] then 221 | if commands[2] then 222 | local system = self:FindSystemByName(commands[2]) 223 | if system then 224 | ShowSystem(system) 225 | else 226 | local matches = self:FindAllAPIMatches(commands[2]) 227 | ShowSearch(matches) 228 | end 229 | else 230 | OpenDocs() 231 | end 232 | else 233 | API_HandleSlash(self, command) 234 | end 235 | end 236 | 237 | local API_HandleLink = _G.APIDocumentation.HandleAPILink 238 | function _G.APIDocumentation:HandleAPILink(link, copyAPI) 239 | local _, type, name, parentName = (":"):split(link); 240 | local apiInfo = self:FindAPIByName(type, name, parentName); 241 | if (apiInfo and ACD.OpenFrames[app]) and not copyAPI then 242 | ShowSystem(apiInfo) 243 | else 244 | API_HandleLink(self, link, copyAPI) 245 | end 246 | end 247 | 248 | _G.StaticPopupDialogs["COPY_TO_CLIPBOARD"] = { 249 | text = _G.CALENDAR_COPY_EVENT, 250 | button1 = _G.OKAY, 251 | hasEditBox = 1, 252 | maxLetters = 31, 253 | editBoxWidth = 260, 254 | OnShow = function(self, data) 255 | self.editBox:SetText(data); 256 | self.editBox:SetFocus(); 257 | end, 258 | timeout = 0, 259 | exclusive = 1, 260 | whileDead = 1, 261 | hideOnEscape = 1, 262 | enterClicksFirstButton = 1 263 | }; 264 | 265 | function _G.CopyToClipboard(clipboardString) 266 | _G.StaticPopup_Show("COPY_TO_CLIPBOARD", nil, nil, clipboardString) 267 | end 268 | -------------------------------------------------------------------------------- /wow-api-docs.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "." 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /wow-api-docs.toc: -------------------------------------------------------------------------------- 1 | ## Interface: 70100 2 | ## Title: WoW API Docs 3 | ## Notes: A graphical interface for Blizzard's API Documentation 4 | ## LoadWith: Blizzard_APIDocumentation 5 | ## LoadOnDemand: 1 6 | 7 | wow-api-docs.lua 8 | --------------------------------------------------------------------------------