fix(lidl): carry method/event descriptions across the .lidl round-trip

Header-first universal modules go header -> .lidl -> cdylib backend. The
impl-header parser captures /// and /** */ doc comments into method/event
descriptions, but the .lidl serializer emitted only the signature, so the
descriptions were dropped — introspection (lm methods / --json, getMethods)
then showed no docs (regressing the wrap-external-lib + tutorial doctests).

Serialize each method/event's description as a trailing `description "..."`
clause (escaped for the string literal; the lexer already decodes \\ \" \n
\t) and parse it back in parseMethodDef/parseEventDef. Module description
now escaped too. Verified: /// docs survive header -> .lidl -> getMethods.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dario Gabriel Lipicar
2026-06-13 19:25:29 -03:00
co-authored by Claude Opus 4.8
parent 1f18c92096
commit 84280b89d9
2 changed files with 27 additions and 3 deletions
@@ -158,6 +158,14 @@ private:
if (!expect(LidlToken::RParen, "method parameters")) return false;
if (!expect(LidlToken::Arrow, "method return type")) return false;
if (!parseTypeExpr(md.returnType)) return false;
// Optional trailing doc: `-> ret description "..."`. Carries the
// method's doc comment across a .lidl round-trip so introspection
// (lm / getMethods) still surfaces it.
if (at(LidlToken::Description)) {
++m_pos;
if (!at(LidlToken::StringLit)) { error("Expected string after method 'description'"); return false; }
md.description = current().text; ++m_pos;
}
// Restore the return-shape flags from the parsed type so a .lidl
// round-trip carries the same semantics the impl-header parser sets
// (it derives them from C++ types: StdLogosResult -> result,
@@ -185,6 +193,11 @@ private:
if (!expect(LidlToken::LParen, "event parameters")) return false;
if (!parseParams(ed.params)) return false;
if (!expect(LidlToken::RParen, "event parameters")) return false;
if (at(LidlToken::Description)) {
++m_pos;
if (!at(LidlToken::StringLit)) { error("Expected string after event 'description'"); return false; }
ed.description = current().text; ++m_pos;
}
mod.events.append(ed); return true;
}