fix(parse_lua_surface): strip Lua line-comments before matching
Previous implementation matched function-declaration patterns inside Lua line-comments, causing false-positive missing_docs warnings for commented-out forward-compat stubs (e.g. DEPRECATED-MVP placeholders in camera and render libs, 5 each). Pre-process source with gsub to strip "--" through end-of-line before running the two gmatch passes. Block comments (--[[...]]) are not handled; not used in this project's Lua sources. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
init.lua
13
init.lua
@@ -8,6 +8,15 @@ local M = {}
|
|||||||
-- (`function M.foo`) — Lua treats them semantically identical.
|
-- (`function M.foo`) — Lua treats them semantically identical.
|
||||||
-- Returns: { public = ["foo","bar",...], private = ["_baz",...] }
|
-- Returns: { public = ["foo","bar",...], private = ["_baz",...] }
|
||||||
function M.parse_lua_surface(source_string)
|
function M.parse_lua_surface(source_string)
|
||||||
|
-- Strip Lua line-comments (-- to end-of-line) before pattern matching.
|
||||||
|
-- This prevents false-positive matches inside commented-out forward-compat
|
||||||
|
-- stubs (e.g. DEPRECATED-MVP placeholders).
|
||||||
|
-- Block comments (--[[...]]) are not handled; not used in Sporel-lib code.
|
||||||
|
-- Caveat: a literal "--" inside a string would also be stripped; acceptable
|
||||||
|
-- for the lint-tool's purpose (false-negatives in pathological string cases
|
||||||
|
-- are preferable to false-positives on commented stubs).
|
||||||
|
local stripped = string.gsub(source_string, "%-%-[^\n]*", "")
|
||||||
|
|
||||||
local public = {}
|
local public = {}
|
||||||
local private = {}
|
local private = {}
|
||||||
local seen = {}
|
local seen = {}
|
||||||
@@ -23,12 +32,12 @@ function M.parse_lua_surface(source_string)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Form 1: M.foo = function(...)
|
-- Form 1: M.foo = function(...)
|
||||||
for name in string.gmatch(source_string, "M%.([_%w]+)%s*=%s*function") do
|
for name in string.gmatch(stripped, "M%.([_%w]+)%s*=%s*function") do
|
||||||
classify(name)
|
classify(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Form 2: function M.foo(...)
|
-- Form 2: function M.foo(...)
|
||||||
for name in string.gmatch(source_string, "function%s+M%.([_%w]+)") do
|
for name in string.gmatch(stripped, "function%s+M%.([_%w]+)") do
|
||||||
classify(name)
|
classify(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user