atproto_mlf/printer

Print an atproto_lexicon/ast.LexiconDoc as vanilla upstream mlf source, spelled so that parsing the output yields a structurally identical document. Anything mlf cannot express (cid-link, integer enums, non-JSON body encodings, open single-ref unions, descriptions in positions without a doc-comment slot, …) is a PrintError naming the construct and its location; nothing is silently dropped.

The def stored under “main” prints under the NSID-suffix name when that name is free (so implicit promotion re-selects it), and under the literal name main with an @main annotation otherwise. Field order is the document’s property order when that order already reproduces the required/nullable lists, else required fields are emitted first in required order (decoded documents sort properties alphabetically, which loses the original order).

Types

pub type PrintError {
  Inexpressible(location: String, message: String)
}

Constructors

  • Inexpressible(location: String, message: String)

Values

pub fn describe(error: PrintError) -> String
pub fn print(doc: ast.LexiconDoc) -> Result(String, PrintError)
Search Document