pub fn parse_multi_file(
files: JsValue,
entry_point: &str,
) -> Result<JsValue, JsError>Expand description
Parse multiple Beancount files with include resolution.
This function accepts a map of file paths to file contents and an entry point,
resolving include directives across the files. This enables multi-file ledgers
in WASM environments where filesystem access is not available.
On a clean parse, the returned directives are run through the same processing
pipeline as validateMultiFile / queryMultiFile (sort → synth-plugins →
book → regular-plugins, validation excluded), so they are sorted, include
plugin-synthesized Open/Document directives, and have booked amounts —
consistent with the other multi-file surfaces. If parsing produced errors, the
raw parsed directives are returned instead (the pipeline is not run on a
malformed ledger) alongside those errors.
§Arguments
files- A JavaScript object mapping file paths to their contents. Example:{ "main.beancount": "include \"accounts.beancount\"", "accounts.beancount": "..." }entry_point- The main file to start loading from (must exist infiles).
§Returns
A ParseResult with the parsed ledger from all files and any errors.
§Example (JavaScript)
const result = parseMultiFile({
"main.beancount": `
include "accounts.beancount"
2024-01-15 * "Coffee"
Expenses:Food 5.00 USD
Assets:Bank
`,
"accounts.beancount": `
2024-01-01 open Assets:Bank USD
2024-01-01 open Expenses:Food USD
`
}, "main.beancount");