Skip to content

Commit

Permalink
Added API export for LuaCheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seadragon91 committed Nov 22, 2016
1 parent 852dbe9 commit d929fbe
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ CPackSourceConfig.cmake
Server/cuberite_api.lua
Server/official_undocumented.lua
Server/NewlyUndocumented.lua

Server/.luacheckrc
73 changes: 73 additions & 0 deletions Server/Plugins/APIDump/main_APIDump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,75 @@ end



local function DumpLuaCheck(a_API)
LOG("Creating file .luacheckrc...")
local file = io.open(".luacheckrc", "w")

file:write([[
-- This file is the config file for the tool named Luacheck
-- Documentation: http://luacheck.readthedocs.io/en/stable/index.html
-- Ignore unused function and loop arguments
unused_args = false
-- Allow self defined globals
allow_defined = true
-- Ignore this functions
ignore =
{
"Initialize", -- Plugin
"OnDisable", -- Plugin
"RegisterPluginInfoCommands", -- InfoReg.lua
"RegisterPluginInfoConsoleCommands", -- InfoReg.lua
"g_PluginInfo", -- Info.lua
}
-- Ignore files / directories
exclude_files =
{
"tests/" -- CuberitePluginChecker
}
-- All globals from cuberite (classes, enums, functions)
globals =
{
]])

-- Export all global symbols
for _, cls in ipairs(a_API) do
if cls.Name == "Globals" then
-- Global functions
for _, func in ipairs(cls.Functions) do
file:write("\t\"", func.Name, "\",\n")
end

-- Global constants
for _, const in ipairs(cls.Constants) do
file:write("\t\"", const.Name, "\",\n")
end

-- Global constants from all groups
for _, group in pairs(cls.ConstantGroups) do
for _, const in pairs(group.Constants) do
file:write("\t\"", const.Name, "\",\n")
end
end
else
file:write("\t\"", cls.Name, "\",\n")
end
end

file:write("}\n")
file:close()

LOG("Config file .luacheckrc created...")
end





--- Returns true if a_Descendant is declared to be a (possibly indirect) descendant of a_Base
local function IsDeclaredDescendant(a_DescendantName, a_BaseName, a_API)
-- Check params:
Expand Down Expand Up @@ -1803,6 +1872,9 @@ local function DumpApi()

-- Dump all available API objects in format used by ZeroBraneStudio API descriptions:
DumpAPIZBS(API)

-- Export the API in a format used by LuaCheck
DumpLuaCheck(API)

LOG("APIDump finished");
return true
Expand Down Expand Up @@ -2062,3 +2134,4 @@ function Initialize(Plugin)

return true
end

0 comments on commit d929fbe

Please sign in to comment.