From dfa4134106378bec54b9c831a3140b1486bf0d1b Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Sat, 16 May 2026 12:55:27 +0200 Subject: [PATCH] feat: add parse_lua_surface (S2 Phase 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extracts M. = 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) --- init.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/init.lua b/init.lua index 4a8a4ae..9121cd6 100644 --- a/init.lua +++ b/init.lua @@ -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. = function(...)` is public; `M._ = ...` 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