feat: add parse_lua_surface (S2 Phase 1)

Extracts M.<name> = function(...) patterns from Lua source; classifies
underscore-prefix as private. Pure regex-based (Lua patterns); 95%
coverage for idiomatic Sporel-Lib code per spec §4.3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Axel Meyer
2026-05-16 12:55:27 +02:00
parent bb9bee495b
commit dfa4134106

View File

@@ -2,4 +2,20 @@
-- See: meta/docs/superpowers/specs/2026-05-16-api-doc-convention-design.md
local M = {}
-- Extracts public/private surface from Lua source code.
-- Convention: `M.<name> = function(...)` is public; `M._<name> = ...` is private.
-- Returns: { public = ["foo","bar",...], private = ["_baz",...] }
function M.parse_lua_surface(source_string)
local public = {}
local private = {}
for name in string.gmatch(source_string, "M%.([_%w]+)%s*=%s*function") do
if string.sub(name, 1, 1) == "_" then
table.insert(private, name)
else
table.insert(public, name)
end
end
return { public = public, private = private }
end
return M