Documentation
¶
Overview ¶
Package formatter implements a deterministic, comment-preserving TypeRB printer. Parsing happens first; the printer then uses the lossless token stream so comments, strings, percent literals, and heredocs are never lost.
Index ¶
- func Format(source []byte) ([]byte, []diagnostic.Diagnostic)
- func FormatWithOptions(source []byte, options Options) ([]byte, []diagnostic.Diagnostic)
- func NextLineIndent(source []byte) string
- func NextLineIndentWithIndentation(source []byte, indentation string) string
- func ReindentPartial(source []byte) []byte
- func ReindentPartialWithIndentation(source []byte, indentation string) []byte
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(source []byte) ([]byte, []diagnostic.Diagnostic)
func FormatWithOptions ¶ added in v0.3.9
func FormatWithOptions(source []byte, options Options) ([]byte, []diagnostic.Diagnostic)
func NextLineIndent ¶ added in v0.3.17
NextLineIndent returns the indentation for a new line following a tokenizable, possibly incomplete source fragment.
func NextLineIndentWithIndentation ¶ added in v0.3.18
NextLineIndentWithIndentation returns the next-line indentation using the given display unit.
func ReindentPartial ¶ added in v0.3.17
ReindentPartial applies canonical leading indentation to a tokenizable source fragment without requiring the fragment to parse as a complete program. It preserves all non-leading text and the contents of multiline tokens so an interactive editor can safely call it while a submission is still open.
func ReindentPartialWithIndentation ¶ added in v0.3.18
ReindentPartialWithIndentation applies leading indentation using the given display unit. It is intended for interactive editors that keep canonical formatting at submission boundaries but need a different on-screen width.