Skip to content

Commit

Permalink
Fix luacheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 20, 2023
1 parent a8bd420 commit 43fbdb3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions tool/jml-docgen/src/doxygen.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json = require("json")
strings = require("strings")
testing = require("testing")
local json = require("json")
local strings = require("strings")
local testing = require("testing")

local juce_root = "~/Developer/tobiashienzsch/JUCE"

Expand Down Expand Up @@ -69,7 +69,7 @@ local function parse_return_type(e)

for _, template in pairs({"std::unique_ptr", "std::optional"}) do
if string.find(ret_type, template) then
template_arg = nil
local template_arg = nil
ret_type:gsub("<([%w%s_]+)>", function(captured)
template_arg = captured
end)
Expand Down
3 changes: 2 additions & 1 deletion tool/jml-docgen/src/json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ local function escape_char(c)
end

local function encode_nil(val)
assert(val == nil)
return "null"
end

Expand Down Expand Up @@ -76,7 +77,7 @@ local function encode_table(val, stack)
error("invalid table: sparse array")
end
-- Encode
for i, v in ipairs(val) do
for _, v in ipairs(val) do
table.insert(res, encode(v, stack))
end
stack[val] = nil
Expand Down
16 changes: 7 additions & 9 deletions tool/jml-docgen/src/ldoc.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
doxygen = require("doxygen")
sol2 = require("sol2")
strings = require("strings")
tables = require("tables")
local doxygen = require("doxygen")
local sol2 = require("sol2")
local strings = require("strings")
local tables = require("tables")

local ldoc = {}

function ldoc.write_usertype_stubs(dir, modules)
local docs, _ = sol2.parse_juce_types(modules)

for module_name, juce_module in pairs(docs) do
for _, juce_module in pairs(docs) do
for class_name, class in pairs(juce_module[2]) do
local doxygen_spec = doxygen.parse_xml(class_name)
if doxygen_spec == nil then
Expand Down Expand Up @@ -41,7 +41,7 @@ function ldoc.write_usertype_stubs(dir, modules)
if tables.length(members_variables) > 0 then
file:write("--- Public variables of the class\n")
file:write("-- @table Variables\n")
for name, var in pairs(members_variables) do
for name, _ in pairs(members_variables) do
file:write(string.format("-- @field %s\n", name))
end
file:write("\n\n")
Expand Down Expand Up @@ -88,12 +88,10 @@ function ldoc.write_usertype_stubs(dir, modules)
end

-- Static or member function
local seperator = nil
local seperator = ":"
if member_dox.is_static then
seperator = "."
file:write(string.format("-- @static\n"))
else
seperator = ":"
end

-- Function parameter
Expand Down
4 changes: 2 additions & 2 deletions tool/jml-docgen/src/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ldoc = require("ldoc")
markdown = require("markdown")
local ldoc = require("ldoc")
local markdown = require("markdown")

local classes = {
juce_core = {
Expand Down
9 changes: 5 additions & 4 deletions tool/jml-docgen/src/markdown.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local sol2 = require("sol2")

local markdown = {}

local function format_usertype_as_code_block(doc)
Expand All @@ -11,7 +13,7 @@ local function format_usertype_as_code_block(doc)
local str = string.format("## %s\n\n", doc.name)
str = str .. string.format("```lua\n")
for i = 1, #doc.members do
func = doc.members[i]
local func = doc.members[i]
if ignored_functions[func] == nil then
str = str .. string.format("juce.%s.%s(...)\n", doc.name, func)
end
Expand All @@ -37,9 +39,8 @@ function markdown.write_usertype(file, modules)
for d = 1, #module_docs[1] do
local name = module_docs[1][d]
local class = module_docs[2][name]
local name = class.name
if name ~= nil then
file:write(string.format(" - [%s](#%s)\n", name, name))
if class.name ~= nil then
file:write(string.format(" - [%s](#%s)\n", class.name, class.name))
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion tool/jml-docgen/src/sol2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ local function parse_usertype(obj)
local name = meta.__name
local doc = {name = nil, members = {}}

local i
local j
i, j = string.find(name, "lua_juce")
if i == nil or j == nil then
doc.name = string.sub(meta.__name, 11) -- Remove "sol.juce::"
Expand Down Expand Up @@ -94,7 +96,7 @@ end

local function write_all_juce_types(file_path)
local types = io.open(file_path, "w")
for k, v in pairs(juce) do
for k, _ in pairs(juce) do
types:write(string.format("%s\n", k))
end
types:close()
Expand Down
6 changes: 2 additions & 4 deletions tool/jml-docgen/src/strings.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing = require("testing")
local testing = require("testing")

local strings = {}

Expand All @@ -11,11 +11,9 @@ function strings.trim(str)
end

function strings.remove_last(str, substr)
local start, stop
local last_pos = 0

repeat
start, stop = str:find(substr, last_pos + 1)
local start, _ = str:find(substr, last_pos + 1)
if start then
last_pos = start
end
Expand Down

0 comments on commit 43fbdb3

Please sign in to comment.