Skip to content

l0.MoonCats

MoonCats = require "l0.MoonCats"
local MoonCats = require("l0.MoonCats")

MoonCats

Extracts LuaCATS annotations from MoonScript sources into LuaLS .d.lua type-definition files and rendered API documentation.

Constructor

moonCats = MoonCats!
local moonCats = MoonCats()

Creates an extractor.

Instance methods

extractPackage

moonCats\extractPackage sources
moonCats:extractPackage(sources)

Extracts type-definition files for a set of modules, resolving cross-module references against every module in the set.

param type description
sources MoonCatsSource[] The modules to extract, each with its require identifier.

Returns:

renderDocs

moonCats\renderDocs sources, opts
moonCats:renderDocs(sources, opts)

Renders API documentation pages for a set of modules, resolving cross-module references and type links against every module in the set.

param type description
sources MoonCatsSource[] The modules to document, each with its require identifier.
opts? MoonCatsDocOptions

Returns:

extractModule

moonCats\extractModule source, requireId
moonCats:extractModule(source, requireId)

Extracts the type-definition file for a single module without cross-module context.

param type description
source string The module's MoonScript source text.
requireId string Require identifier the module resolves under.

Returns:

  • definition string? — The definition text, or nil when the module fails to parse.
  • diagnostics MoonCatsDiagnostics — All findings from the run.

Fields

field type description
Parser MoonCatsParser
Emitter MoonCatsEmitter
DocRenderer MoonCatsDocRenderer
Diagnostics MoonCatsDiagnostics

Types

MoonCatsSource

One MoonScript module handed to an extraction run.

field type description
requireId string Require identifier the module resolves under.
source string The module's MoonScript source text.

MoonCatsExtractionResult

The outcome of an extraction run.

field type description
definitions {requireId: string, text: string}[] One definition file per successfully parsed module, in input order.
diagnostics MoonCatsDiagnostics All findings from parsing and emission.