formatter 0.0.2-preview.1

A code formatter for Zena

Readme Files Dependencies Versions

formatter#

A code formatter for Zena source code, built on a Wadler/Prettier-style document intermediate representation (Doc).

Usage#

Formatting Zena Source#

import { format } from 'formatter';

let formatted = format('export function add(a:i32,b:i32):i32{return a+b;}');

Building Custom Documents#

You can also construct and print Doc trees directly using formatter/doc and formatter/doc-printer:

import { group, concat, text, line } from 'formatter/doc';
import { printDocToString, PrintOptions } from 'formatter/doc-printer';

let doc = group(concat([text('a,'), line, text('b')]));
let rendered = printDocToString(doc, new PrintOptions(80));

Libraries#

  • formatter / formatter/printer — Zena AST printer (format, printModuleToDoc)
  • formatter/doc — document IR builders (Doc, text, concat, group, indent, line, softline, hardline, ifBreak, join, fill, lineSuffix)
  • formatter/doc-printer — line-breaking document renderer (printDocToString, PrintOptions)

License#

MIT

667 bytes Raw
{
  "name": "zena-lang:formatter",
  "did": "did:plc:dqgljfputbfioi44rdhvimwu",
  "version": "0.0.2-preview.1",
  "description": "A code formatter for Zena",
  "license": "MIT",
  "files": [
    "src"
  ],
  "main": "printer",
  "exports": {
    "doc": {},
    "doc-printer": {},
    "printer": {}
  },
  "dependencies": {
    "compiler": {
      "path": "../compiler",
      "version": "0.0.2-preview.1"
    }
  },
  "scripts": {
    "test": {
      "type": "zena:test",
      "tests": "test/*_test.zena",
      "files": [
        "test/**/*.zena",
        "../../tests/language/**/*.zena"
      ],
      "dependencies": [
        "../cli:build"
      ]
    }
  }
}
  • compiler compiler.zena-lang.pkg.zena-lang.dev 0.0.2-preview.1
VersionPublishedDependenciesApproved by
0.0.2-preview.1 2026-11-19
  • compiler compiler.zena-lang.pkg.zena-lang.dev 0.0.2-preview.1