Expand description
Opinionated CST-backed formatter entries.
Sole import path for the formatter surface - format_source,
format_source_with_parsed, try_format_source, format_node,
format_node_range, format_node_with_alignment,
format_node_range_with_alignment, PostingAlignment,
compute_alignment, canonicalize_directives,
CanonicalizeError, lf_to_crlf_outside_strings,
crlf_to_lf_outside_strings, cr_outside_strings_present. The
flat crate-root re-exports were removed in round-5 and the
duplicate crate::cst::format path was sealed in round-6 of
the PR #1284 reviews, so a future deprecation can be done at
exactly one site.
Structs§
- Posting
Alignment - Pre-computed alignment data for a whole source file.
Enums§
- Canonicalize
Error - Error returned by
canonicalize_directives.
Functions§
- canonicalize_
directives - Render typed Beancount
Directives in the canonical form emitted byformat_source. - compute_
alignment - Compute the file-wide alignment columns for a parsed
SourceFile. - cr_
outside_ strings_ present trueiffsrccontains at least one\rbyte OUTSIDE a string literal — i.e. the byte sequence the canonical formatter would fold to\nviacrlf_to_lf_outside_strings.- crlf_
to_ lf_ outside_ strings - Replace CRLF and bare-CR line terminators with LF, but ONLY outside string literals.
- format_
node - Format a
SOURCE_FILEsyntax node in opinionated canonical form. - format_
node_ range - Format the subset of
node’s top-level children that intersectrange, returning the snapped byte range and the canonical-form replacement text. - format_
node_ range_ with_ alignment - Like
format_node_rangebut skips the per-callcompute_alignmentwalk by accepting a precomputedPostingAlignment. - format_
node_ with_ alignment - Like
format_nodebut skips the per-callcompute_alignmentwalk by accepting a precomputedPostingAlignment. - format_
source - Format a Beancount source file in opinionated canonical form.
- format_
source_ with_ parsed - Like
format_sourcebut reuses the caller’scrate::ParseResultinstead of re-parsingsource. - lf_
to_ crlf_ outside_ strings - Convert every
\nline terminator OUTSIDE string literals back to\r\n, leaving\ncharacters inside strings (and inside comments… see below) untouched. - try_
format_ source - Like
format_source, but returns the parse errors instead of silently formatting around them.