Crate topiary_core

Crate topiary_core 

Source
Expand description

A general code formatter that relies on Tree-sitter for language parsing.

In order for a language to be supported, there must be a Tree-sitter grammar available, and there must be a query file that dictates how that language is to be formatted. We include query files for some languages.

More details can be found on GitHub.

Structs§

CoverageData
Language
A Language contains all the information Topiary requires to format that specific languages.
ScopeInformation
SyntaxNode
TopiaryQuery
Topiary often needs both the tree-sitter Query and the original content belonging to the file from which the query was parsed. This struct is a simple convenience wrapper that combines the Query with its original string.

Enums§

Atom
An atom represents a small piece of the output. We turn Tree-sitter nodes into atoms, and we add white-space atoms where appropriate. The final list of atoms is rendered to the output.
Capitalisation
FormatterError
The various errors the formatter may return.
IoError
A subtype of FormatterError::Io
Operation
Operations that can be performed by the formatter.
ScopeCondition
Used in Atom::ScopedConditional to apply the containing Atoms only if the matched node spans a single line or multiple lines
Visualisation
Supported visualisation formats

Functions§

apply_query
Applies a query to an input content and returns a collection of atoms.
check_query_coverage
Check if the input tests all patterns in the query, by successively disabling all patterns. If disabling a pattern does not decrease the number of matches, then that pattern originally matched nothing in the input.
formatter
The function that takes an input and formats, or visualises an output.
formatter_str
The function that takes a string slice and formats, or visualises an output.
formatter_tree
The function that takes a tree and formats, or visualises an output.
parse
Parses some string into a syntax tree, given a tree-sitter grammar.

Type Aliases§

FormatterResult
A convenience wrapper around std::result::Result<T, FormatterError>.