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:
Axel Meyer
2026-05-16 17:51:10 +02:00
parent 2e72de2ea6
commit 78cf0eb980

View File

@@ -8,6 +8,15 @@ local M = {}
-- (`function M.foo`) — Lua treats them semantically identical.
-- Returns: { public = ["foo","bar",...], private = ["_baz",...] }
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 private = {}
local seen = {}
@@ -23,12 +32,12 @@ function M.parse_lua_surface(source_string)
end
-- 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)
end
-- 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)
end