Skip to content

Modules

A module is how you package and ship actions so BeDoc can discover them. In practice a module is an npm package whose package.json lists its action files under a bedoc.actions array.

Each action lives in its own JavaScript file and default-exports a single action class (parser or formatter):

import { ActionBuilder } from "@gesslar/actioneer"
export default class MyParser {
static meta = Object.freeze({
kind: "parser",
input: "mylang",
terms: "ref://./bedoc-mylang-parser.yaml",
})
setup = builder => builder.do("Parse", this.#parse)
#parse = ctx => ({ functions: [] })
}

Each file’s contract lives in a separate Terms file referenced by meta.terms.

List each action file in your package.json under bedoc.actions. A single package may provide any number of parsers and formatters:

{
"name": "bedoc-mylang",
"version": "1.0.0",
"type": "module",
"bedoc": {
"actions": [
"./bedoc-mylang-parser.js",
"./bedoc-markdown-formatter.js"
]
}
}

Follow BeDoc’s naming so your modules are easy to find and recognise:

Action Package name pattern
Parser bedoc-<language>-parser
Formatter bedoc-<format>-formatter

When installed (locally or globally), BeDoc scans node_modules for packages with a bedoc entry and loads the files listed in bedoc.actions. It then validates each action’s meta and contract before pairing a parser with a formatter.

Read more in the Discovery guide. For local iteration you can skip packaging entirely and point BeDoc straight at a file with --parser / --formatter, or at a directory of mocks with --mock.