summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2016-11-23 07:36:13 +0100
committerGitHub <noreply@github.com>2016-11-23 07:36:13 +0100
commit59f34ab8012da8a1c8f8079d620021f810c1a4e4 (patch)
treeb72f2b244a72365bb72aee90a023f82500621c54
parentMerge pull request #3440 from cuberite/FixWolfTarget (diff)
parentAdded API export for LuaCheck. (diff)
downloadcuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar.gz
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar.bz2
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar.lz
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar.xz
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.tar.zst
cuberite-59f34ab8012da8a1c8f8079d620021f810c1a4e4.zip
-rw-r--r--.gitignore2
-rw-r--r--Server/Plugins/APIDump/main_APIDump.lua73
2 files changed, 74 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index bb046dd98..488ae822f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -107,4 +107,4 @@ CPackSourceConfig.cmake
Server/cuberite_api.lua
Server/official_undocumented.lua
Server/NewlyUndocumented.lua
-
+Server/.luacheckrc
diff --git a/Server/Plugins/APIDump/main_APIDump.lua b/Server/Plugins/APIDump/main_APIDump.lua
index df2d933f8..a6824c29d 100644
--- a/Server/Plugins/APIDump/main_APIDump.lua
+++ b/Server/Plugins/APIDump/main_APIDump.lua
@@ -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:
@@ -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
@@ -2062,3 +2134,4 @@ function Initialize(Plugin)
return true
end
+