Skip to content

Commit

Permalink
Project commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Grogir committed Feb 25, 2019
0 parents commit 3b13be4
Show file tree
Hide file tree
Showing 33 changed files with 5,735 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/_archive
/lua*
/notepad-plus-plus
/release*/
/dll/Win32
/dll/x64
/dll/.vs
/dll/*.user
/api/raw.githubusercontent.com
/api/wow.gamepedia.com
/api/wowprogramming.com
/api/completion.xml
/api/highlight.xml
1 change: 1 addition & 0 deletions api/Ace3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ace3 AceAddon30Frame AceComm30Frame AceEvent30Frame AddToBlizOptions CancelAllTimers CancelTimer ChatThrottleLib ClearFocus Close CloseAll ConfigTableChanged Create CreateChatCommand Deserialize Despool Disable DisableAddon DisableModule Embed EmbedLibraries EmbedLibrary Enable EnableAddon EnableModule Enqueue FeedGroup GetAddon GetArgs GetChatCommandOptions GetLayout GetLibrary GetLocale GetModule GetName GetNextWidgetNum GetOptionsTable GetStatusTable GetWidgetCount GetWidgetVersion HandleCommand Hook HookScript Hook_SendAddonMessage Hook_SendChatMessage Init InitializeAddon IsEnabled IsHooked IsModule IsTabCompletionRegistered IterateAddonStatus IterateAddons IterateChatCommands IterateEmbeds IterateEmbedsOnAddon IterateLibraries IterateModules IterateModulesOfAddon IterateOptionsTables LibStub New NewAddon NewLibrary NewLocale NewModule NotifyChange OnEmbedDisable OnEmbedEnable OnEvent OnInitialize OnReceiveMultipartFirst OnReceiveMultipartLast OnReceiveMultipartNext OnTabPressed OnUpdate Open Print PrintCmd Printf RawHook RawHookScript RegisterAsContainer RegisterAsWidget RegisterBucketEvent RegisterBucketMessage RegisterCallback RegisterChatCommand RegisterComm RegisterEvent RegisterLayout RegisterMessage RegisterOptionsTable RegisterTabCompletion RegisterWidgetType Release ScheduleRepeatingTimer ScheduleTimer SecureHook SecureHookScript SelectGroup SendAddonMessage SendChatMessage SendCommMessage SendMessage Serialize SetDefaultModuleLibraries SetDefaultModulePrototype SetDefaultModuleState SetDefaultSize SetEnabledState SetFocus TimeLeft Unhook UnhookAll UnregisterAllBuckets UnregisterAllCallbacks UnregisterAllComm UnregisterAllEvents UnregisterAllMessages UnregisterBucket UnregisterCallback UnregisterChatCommand UnregisterComm UnregisterEvent UnregisterMessage UnregisterTabCompletion UpdateAvail ValidateOptionsTable _RegisterComm
48 changes: 48 additions & 0 deletions api/common.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--------------------------------------------------
--
-- common.lua
-- created on 17/02/2019
-- by Grogir
-- Licence: GNU GPL
--
--------------------------------------------------

package.cpath="luasocket/?.dll"
package.path="luasocket/?.lua"
http=require("socket.http")
https=require("ssl.https")

function getfile(path)
local f=io.open(path)
local all=f:read("*a")
f:close()
return all
end

function getpage(fullpath)
local proto,path=fullpath:match("^(https?)://(.+)$")
assert(proto and path)
f=io.open(path)
if not f then
f=io.open(path,"w+")
assert(f,"can't create "..path)
local page=proto=="https" and https.request(fullpath) or http.request(fullpath)
assert(page,"no such webpage "..fullpath)
f:write(page)
f:seek("set",0)
print(path.." downloaded")
end
local all=f:read("*a")
f:close()
return all
end

function mkdir(path)
local sep=package.config:sub(1,1)
if sep=="\\" then
path=path:match("://(.+)$"):gsub("/",sep)
os.execute("if not exist "..path.." mkdir "..path)
else
os.execute("mkdir -p "..path:match("://(.+)$"))
end
end
14 changes: 14 additions & 0 deletions api/completion.model.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
LuaWoW - AutoComplete
Author: Grogir
Licence: GNU GPL
This file has been auto-generated with documentation from lua.org, wow.gamepedia.com, wowprogramming.com
-->
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<Environment ignoreCase="no" startFunc="(" stopFunc=")" paramSeparator="," terminal=";" additionalWordChar = ".:"/>
<AutoComplete language="LUA">

<!-- KEYWORDS -->
</AutoComplete>
</NotepadPlus>
188 changes: 188 additions & 0 deletions api/generate_completion.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
--------------------------------------------------
--
-- AutoComplete Generator
-- created on 17/02/2019
-- by Grogir
-- Licence: GNU GPL
--
--------------------------------------------------

dofile("common.lua")
respath="https://raw.githubusercontent.com/Resike/BlizzardInterfaceResources/master/Resources"
mkdir(respath.."/Data")

function trim(s)
return s and s:match"^%s*(.*%S)"
end
function purge(s)
return s and s:gsub("?",""):gsub("<.->",""):gsub('"',"'"):gsub("&amp;","&"):gsub("&#160;"," "):gsub("&nbsp;"," "):gsub("&#10;"," "):gsub("&#039;","'"):gsub("&quot;","'"):gsub("&lt;","<"):gsub("&gt;",">")
end
function cut(str)
act=1
while str:len()>act+99 do
nl=str:find("\n",act)
if not nl or nl>act+100 then
str=str:sub(1,act+99).."\n"..str:sub(act+100)
act=act+101
else
act=nl+1
end
end
return str
end

-- 1. Get all entries we want to include

db={}
all=getpage(respath.."/Data/GlobalTypes.lua.txt") -- globals
for name,type in all:gmatch('(%S+) = "(%S+)"') do
if type~="string" and type~="number" and type~="boolean" then
db[name]={func=type=="function",ov={}}
end
end
for _,file in ipairs({"/APILua.lua","/APIC.lua","/WidgetAPI.lua"}) do -- "module.func" functions
all=getpage(respath..file)
for name in all:gmatch("[^%s:%(%)]+") do
db[name]=db[name] or {func=true,ov={}}
local module,func=name:match("^([^.]-)%.?([^.]+)$")
db[module]=nil -- adding those is unnecessary
db[func]=db[func] or {func=true,ov={}}
end
end
all=getfile("Ace3.txt") -- ace3 functions
for name in all:gmatch("%S+") do
db[name]={func=true,ov={}}
end
all=getpage(respath.."/Events.lua") -- events
for name in all:gmatch('[^%s"]+') do
db[name]={func=false,ov={}}
end

-- 2. Fill with standard lua doc

all=getfile("lua.xml")
for name,content in all:gmatch('Word name="([^"]+)"(.-)<Key') do
if db[name] and content:find('<Overload retVal="') then
local module,func=name:match("^([^.]-%.?)([^.]+)$")
db[func].doc=trim(content:gsub("Â",""):gsub("·","."):gsub('"void"','"'..module..'"'))
end
end

-- 3. Fill with wowpedia doc

website="https://wow.gamepedia.com"
mkdir(website)

all=getpage(website.."/World_of_Warcraft_API")..getpage(website.."/Widget_API")
done={}

for tags,link,name,info in all:gmatch('<dd>([^<]-)<a href="(.-API_.-)".->(.-)</a>(.-)</dd>') do
if not done[link] then
done[link]=true
info=trim(purge(info)) or ""
local sign=trim(info:match("^%(([^)]*)%)"))
local desc=trim((sign and info:sub(#sign+2) or info):match("[() -]*(.-)$"))
if desc and desc:match("^[aA]dded in") then print(name,desc) end
if not desc or #desc<12 or desc:find("not yet docu") then
desc=nil
end
if sign then
sign="("..sign..")"
end

if link:sub(1,5)=="/API_" then
local page=getpage(website..link)
desc=trim(purge(page:match('<meta name="description" content="(.-)"/>'))) or desc
sign=trim(purge(page:match('<div class="mw%-parser%-output">.-<h2>'):match("<pre>(.-)</pre>"))) or sign
end

if desc or sign then
local module,func=name:match("^([^.:]-[.:]?)([^.:]+)$")
if db[func] then
db[func].ov[module]={sign=sign,desc=desc}
end
end
end
end
print(website.." done")

-- 4. Fill with wowprogramming doc

website="http://wowprogramming.com"
mkdir(website.."/docs/api")

all=getpage(website.."/docs/api.html")

for link,name,info in all:gmatch('<tr><td><a href="(.-)">(.-)</a></td><td>(.-)<') do
local page=getpage(website..link)
local desc=trim(purge(page:match("<div class=\"api%-desc\">\n\n<p>(.-)</div>")))
local sign=trim(purge(page:match("<div class=\"signature\">\n\n<p>(.-)</p>\n</div>")))

if desc or sign then
local module,func=name:match("^([^.:]-[.:]?)([^.:]+)$")
if db[func] then
db[func].ov[module]=db[func].ov[module] or {}
local ov=db[func].ov[module]
ov.sign=ov.sign or sign
ov.desc=ov.desc or desc
end
end
end
print(website.." done")

-- 5. Write the file

fmodel=io.open("completion.model.xml")
model=fmodel:read("*a")
fmodel:close()
modelbegin,modelend=model:find("<!-- KEYWORDS -->",1,true)

sorted={}
for k,v in pairs(db) do
if not db[k:lower()] or k==k:lower() then
table.insert(sorted,k)
end
end
table.sort(sorted)
f=io.open("completion.xml","w")
f:write(model:sub(1,modelbegin-1))
for _,name in ipairs(sorted) do
local t=db[name]
if t.doc then
f:write('\t\t<KeyWord name="'..name..'" '..t.doc..'\n')
elseif next(t.ov) then
f:write('\t\t<KeyWord name="'..name..'" func="yes">\n')
for module,func in pairs(t.ov) do
local desc=func.desc and cut('\n'..func.desc) or ''
if not func.sign then
f:write('\t\t\t<Overload retVal="" descr="'..desc..'"/>\n')
else
local ret=cut(func.sign:match('.-=') or '')
ret=#ret>0 and #module>0 and ret..' '..module or ret..module

for args in func.sign:gmatch('%((.-)%)') do
if trim(args) then
f:write('\t\t\t<Overload retVal="'..ret..'" descr="'..desc..'">\n')
for param in args:gmatch('([^,]+)') do
f:write('\t\t\t\t<Param name="'..trim(param)..'"/>\n')
end
f:write('\t\t\t</Overload>\n')
else
f:write('\t\t\t<Overload retVal="'..ret..'" descr="'..desc..'"/>\n')
end
end
end
end
f:write('\t\t</KeyWord>\n')
else
f:write('\t\t<KeyWord name="'..name..'" func="'..(t.func and 'yes' or 'no')..'"/>\n')
end
end
f:write(model:sub(modelend+1))
f:close()

print("done")




74 changes: 74 additions & 0 deletions api/generate_highlight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
--------------------------------------------------
--
-- Syntax Highlighting Generator
-- created on 17/02/2019
-- by Grogir
-- Licence: GNU GPL
--
--------------------------------------------------

dofile("common.lua")
path="https://raw.githubusercontent.com/Resike/BlizzardInterfaceResources/master/Resources"
mkdir(path.."/Data")

function exists(name)
return luaglobals and luaglobals[name] or api and api[name] or ui and ui[name]
end
function getmap(all)
local map,name={}
for name in all:gmatch("[^%s:%(%)]+") do
if not exists(name) then
map[name:match("[^%.]+$")]=true
end
end
return map
end
function getsortednames(map)
local sorted,name,_={}
for name,_ in pairs(map) do
table.insert(sorted,name)
end
local txt=""
table.sort(sorted)
for _,name in ipairs(sorted) do
txt=txt.." "..name
end
return txt:sub(2)
end


out=getfile("highlight.model.xml")


-- lua globals
luaglobals=getmap(getpage(path.."/APILua.lua"))
out=out:gsub("<!%-%- LUAGLOBALS %-%->",getsortednames(luaglobals))

-- api
api=getmap(getpage(path.."/API.lua").."\n"..getpage(path.."/APIC.lua"))
out=out:gsub("<!%-%- API %-%->",getsortednames(api))

-- ui + ace3
ui=getmap(getpage(path.."/WidgetAPI.lua").."\n"..getfile("Ace3.txt"))
out=out:gsub("<!%-%- UI %+ ACE3 %-%->",getsortednames(ui))

-- global tables
all=getpage(path.."/Data/GlobalTypes.lua.txt")
tables={}
for name,type in all:gmatch('(%S+) = "(%S+)"') do
if type~="string" and type~="function" and type~="number" and type~="boolean" and not exists(name) then
tables[name]=true
end
end
out=out:gsub("<!%-%- TABLES %-%->",getsortednames(tables))


f=io.open("highlight.xml","w")
f:write(out)
f:close()

print("done")




Loading

0 comments on commit 3b13be4

Please sign in to comment.