### Run Examples with Fancy-Regex Engine Source: https://github.com/trishume/syntect/blob/master/Readme.md This command demonstrates how to run syntect examples using the fancy-regex engine. It specifies the 'default-fancy' feature and disables default features for the cargo run command. ```bash cargo run --features default-fancy --no-default-features --release --example syncat testdata/highlight_test.erb ``` -------------------------------- ### Highlight Lines of Code to Terminal Source: https://github.com/trishume/syntect/blob/master/Readme.md This example demonstrates how to load default syntax and theme sets, find a syntax by file extension, and highlight lines of a string, outputting the result with 24-bit terminal escape sequences. Ensure you have a terminal that supports 24-bit color. ```rust use syntect::easy::HighlightLines; use syntect::parsing::SyntaxSet; use syntect::highlighting::{ThemeSet, Style}; use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; // Load these once at the start of your program let ps = SyntaxSet::load_defaults_newlines(); let ts = ThemeSet::load_defaults(); let syntax = ps.find_syntax_by_extension("rs").unwrap(); let mut h = HighlightLines::new(syntax, &ts.themes["base16-ocean.dark"]); let s = "pub struct Wow { hi: u64 }\nfn blah() -> u64 {}"; for line in LinesWithEndings::from(s) { let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ps).unwrap(); let escaped = as_24_bit_terminal_escaped(&ranges[..], true); print!("{}", escaped); } ``` -------------------------------- ### Syntect Parsing Performance - Stats Branch Source: https://github.com/trishume/syntect/blob/master/DESIGN.md Measures the performance of Syntect's parsing by counting specific log messages on the 'stats' branch using the 'syncat' example. ```bash $cargo run --release --example syncat testdata/jquery.js | grep cmiss | wc -l Running `target/release/examples/syncat testdata/jquery.js` 61266 ``` ```bash $cargo run --release --example syncat testdata/jquery.js | grep ptoken | wc -l Compiling syntect v0.1.0 (file:///Users/tristan/Box/Dev/Projects/syntect) Running `target/release/examples/syncat testdata/jquery.js` 98714 ``` ```bash $wc -l testdata/jquery.js 9210 testdata/jquery.js ``` ```bash $cargo run --release --example syncat testdata/jquery.js | grep cclear | wc -l Compiling syntect v0.1.0 (file:///Users/tristan/Box/Dev/Projects/syntect) Running `target/release/examples/syncat testdata/jquery.js` 71302 ``` ```bash $cargo run --release --example syncat testdata/jquery.js | grep freshcachetoken | wc -l Compiling syntect v0.1.0 (file:///Users/tristan/Box/Dev/Projects/syntect) Running `target/release/examples/syncat testdata/jquery.js` 80512 ``` -------------------------------- ### Ruby Nesting with Heredocs Source: https://github.com/trishume/syntect/blob/master/testdata/test3.html This example shows Ruby code embedded within an ERB template, featuring nested string interpolation and custom heredoc endings. Note the highlighting differences for evaluated vs. unevaluated heredoc content. ```ruby puts "Ruby #{'nesting' * 2}" here = <<-WOWCOOL \+ CORRECTLY_DOES_NOT_HIGHLIGHT_REST_OF_LINE high quality parsing even supports custom heredoc endings #{ nested = 5 * <<-ZOMG nested heredocs! (no highlighting: 5 * 6, yes highlighting: #{5 * 6}) ZOMG } WOWCOOL ``` ```sql select * from heredocs where there_are_special_heredoc_names = true SQL ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/trishume/syntect/blob/master/Readme.md Run this command if you have cloned the repository to fetch all required dependencies for running tests. ```bash git submodule update --init ``` -------------------------------- ### Highlighting Structures and Methods Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt This section details the primary structures used for syntax highlighting in syntect, including Highlighter, HighlightState, and RangedHighlightIterator, along with their methods. ```APIDOC ## syntect::highlighting::HighlightState ### Description Represents the state of syntax highlighting for a given text, including the current scope stack. ### Methods - `new(highlighter: &syntect::highlighting::Highlighter<'_>, initial_stack: syntect::parsing::ScopeStack) -> syntect::highlighting::HighlightState`: Creates a new `HighlightState`. - `clone(&self) -> syntect::highlighting::HighlightState`: Clones the current `HighlightState`. - `eq(&self, other: &syntect::highlighting::HighlightState) -> bool`: Compares two `HighlightState` instances for equality. ### Traits Implemented - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::PartialEq` - `core::fmt::Debug` - `core::marker::StructuralPartialEq` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ## syntect::highlighting::Highlighter<'a> ### Description Manages syntax highlighting, providing access to themes and generating styles for scope stacks. ### Methods - `get_default(&self) -> syntect::highlighting::Style`: Retrieves the default style. - `new(theme: &'a syntect::highlighting::Theme) -> syntect::highlighting::Highlighter<'a>`: Creates a new `Highlighter` with the specified theme. - `style_for_stack(&self, stack: &[syntect::parsing::Scope]) -> syntect::highlighting::Style`: Determines the style for a given scope stack. - `style_mod_for_stack(&self, path: &[syntect::parsing::Scope]) -> syntect::highlighting::StyleModifier`: Gets the style modifier for a scope stack path. ### Traits Implemented - `core::fmt::Debug` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ## syntect::highlighting::RangedHighlightIterator<'a, 'b> ### Description An iterator that yields highlighted ranges of text, suitable for processing text in chunks. ### Associated Types - `Item = (syntect::highlighting::Style, &'b str, core::ops::range::Range)`: The type of item yielded by the iterator, consisting of a style, a text slice, and a range. ### Methods - `new(state: &'a mut syntect::highlighting::HighlightState, changes: &'a [(usize, syntect::parsing::ScopeStackOp)], text: &'b str, highlighter: &'a syntect::highlighting::Highlighter<'_>) -> syntect::highlighting::RangedHighlightIterator<'a, 'b>`: Creates a new `RangedHighlightIterator`. - `next(&mut self) -> core::option::Option<(syntect::highlighting::Style, &'b str, core::ops::range::Range)>`: Returns the next highlighted range. ### Traits Implemented - `core::fmt::Debug` - `core::iter::traits::iterator::Iterator` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` ## syntect::highlighting::ScopeSelector ### Description Used to select scopes based on a defined path and exclusions. ### Fields - `path: syntect::parsing::ScopeStack`: The scope path to match. - `excludes: alloc::vec::Vec`: A list of scope stacks to exclude. ### Methods - `does_match(&self, stack: &[syntect::parsing::Scope]) -> core::option::Option`: Checks if the selector matches the given scope stack and returns the match power if it does. ``` -------------------------------- ### Syntect Easy HighlightFile API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Provides an easy-to-use interface for highlighting the content of a file. ```APIDOC ## HighlightFile::new ### Description Creates a new `HighlightFile` instance for a given file path. ### Method `HighlightFile::new` ### Parameters - `path_obj` (*P*): The path to the file. Must implement `core::convert::AsRef`. - `ss` (*&syntect::parsing::SyntaxSet*): The syntax set to use for highlighting. - `theme` (*&'a syntect::highlighting::Theme*): The theme to use for highlighting. ### Returns - `core::result::Result, std::io::error::Error>`: A new `HighlightFile` instance or an I/O error. ### Fields - `highlight_lines`: A `HighlightLines` instance for processing lines. - `reader`: A buffered reader for the file. ``` -------------------------------- ### syntect::parsing::syntax_definition::Context Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the Context struct, detailing its methods and trait implementations. ```APIDOC ## struct syntect::parsing::syntax_definition::Context ### Description Represents a context within syntax definition. ### Methods - `eq(&self, other: &syntect::parsing::syntax_definition::Context) -> bool`: Compares two contexts for equality. ### Trait Implementations - `core::fmt::Debug`: Allows formatting the context for debugging. - `core::marker::StructuralPartialEq`: Provides structural partial equality. - `serde_core::ser::Serialize`: Enables serialization of the context. - `serde_core::de::Deserialize`: Enables deserialization of the context. - `core::marker::Freeze`: Indicates the type is freeze. - `core::marker::Send`: Indicates the type is send. - `core::marker::Sync`: Indicates the type is sync. - `core::marker::Unpin`: Indicates the type is unpin. - `core::panic::unwind_safe::RefUnwindSafe`: Indicates the type is ref unwind safe. - `core::panic::unwind_safe::UnwindSafe`: Indicates the type is unwind safe. ``` -------------------------------- ### Syntect Parsing Performance - With Search Caching Source: https://github.com/trishume/syntect/blob/master/DESIGN.md Evaluates Syntect's parsing performance with search caching enabled, comparing 'searchcached' counts against 'regsearch'. ```bash $cargo run --example syncat testdata/jquery.js | grep searchcached | wc -l Compiling syntect v0.6.0 (file:///Users/tristan/Box/Dev/Projects/syntect) Running `target/debug/examples/syncat testdata/jquery.js` 2440527 ``` ```bash $cargo run --example syncat testdata/jquery.js | grep regsearch | wc -l Running `target/debug/examples/syncat testdata/jquery.js` 950195 ``` -------------------------------- ### SyntaxSetBuilder - Building SyntaxSets Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Facilitates the creation and customization of `SyntaxSet` objects. ```APIDOC ## SyntaxSetBuilder ### Description A builder for creating `SyntaxSet` instances. ### Methods #### `new() -> SyntaxSetBuilder` Creates a new, empty `SyntaxSetBuilder`. #### `default() -> SyntaxSetBuilder` Creates a `SyntaxSetBuilder` with default settings. #### `add(&mut self, syntax: SyntaxDefinition)` Adds a single syntax definition to the builder. #### `add_from_folder>(&mut self, folder: P, lines_include_newline: bool) -> Result<(), LoadingError>` Adds syntax definitions from a folder to the builder. #### `add_plain_text_syntax(&mut self)` Adds the plain text syntax definition to the builder. #### `syntaxes(&self) -> &[SyntaxDefinition]` Returns a slice of the syntax definitions currently in the builder. #### `warnings(&self) -> &[String]` Returns a slice of any warnings encountered during the build process. #### `build(self) -> SyntaxSet` Consumes the builder and returns the constructed `SyntaxSet`. ### Traits #### `Clone` Allows cloning a `SyntaxSetBuilder`. #### `Default` Provides a default `SyntaxSetBuilder`. #### `Send`, `Sync`, `Unpin`, `RefUnwindSafe`, `UnwindSafe` Indicates thread safety and memory safety properties. ``` -------------------------------- ### syntect::highlighting::Theme Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Details about the Theme struct, including its fields, implemented traits, and serialization methods. ```APIDOC ## Struct: syntect::highlighting::Theme ### Description Represents a complete syntax highlighting theme, containing scope selectors and their associated styles. ### Fields - **author** (`core::option::Option`) - The author of the theme. - **name** (`core::option::Option`) - The name of the theme. - **scopes** (`alloc::vec::Vec`) - A list of theme items, mapping scope selectors to styles. - **settings** (`syntect::highlighting::ThemeSettings`) - General settings for the theme. ### Implemented Traits - `core::clone::Clone` - `core::cmp::PartialEq` - `core::default::Default` - `core::fmt::Debug` - `core::marker::StructuralPartialEq` - `serde_core::ser::Serialize` - `serde_core::de::Deserialize` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ### Methods - `clone(&self) -> syntect::highlighting::Theme` - `eq(&self, other: &syntect::highlighting::Theme) -> bool` - `default() -> syntect::highlighting::Theme` - `fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result` ### Serialization - `serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde_core::ser::Serializer>::Ok, <__S as serde_core::ser::Serializer>::Error> where __S: serde_core::ser::Serializer` - `deserialize<__D>(__deserializer: __D) -> core::result::Result::Error> where __D: serde_core::de::Deserializer<'de>` ``` -------------------------------- ### Syntect Highlighting Style Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Details about the `Style` struct, its fields, and associated methods. ```APIDOC ## `syntect::highlighting::Style` ### Description Represents a highlighting style, including background and foreground colors, and font style. ### Fields - **background** (syntect::highlighting::Color) - The background color of the style. - **font_style** (syntect::highlighting::FontStyle) - The font style (e.g., bold, italic). - **foreground** (syntect::highlighting::Color) - The foreground (text) color of the style. ### Methods - **apply**(&self, modifier: syntect::highlighting::StyleModifier) -> syntect::highlighting::Style: Applies a `StyleModifier` to the current style. - **clone**(&self) -> syntect::highlighting::Style: Creates a clone of the style. - **eq**(&self, other: &syntect::highlighting::Style) -> bool: Checks if two styles are equal. - **default**() -> syntect::highlighting::Style: Returns the default style. - **fmt**(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result: Formats the style for debugging. - **hash**<__H: core::hash::Hasher>(&self, state: &mut __H): Hashes the style. - **serialize**<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde_core::ser::Serializer>::Ok, <__S as serde_core::ser::Serializer>::Error> where __S: serde_core::ser::Serializer: Serializes the style. - **deserialize**<__D>(__deserializer: __D) -> core::result::Result::Error> where __D: serde_core::de::Deserializer<'de>: Deserializes the style. ### Traits - `Clone` - `Eq` - `PartialEq` - `Default` - `Debug` - `Hash` - `Copy` - `StructuralPartialEq` - `Serialize` - `Deserialize` - `Freeze` - `Send` - `Sync` - `Unpin` - `RefUnwindSafe` - `UnwindSafe` ``` -------------------------------- ### SyntaxDefinition Loading and Operations Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Provides details on loading SyntaxDefinitions from strings and their associated traits like Clone, Eq, PartialEq, Debug, Serialize, and Deserialize. ```APIDOC ## `syntect::parsing::syntax_definition::SyntaxDefinition` ### Description Represents a parsed syntax definition, used for syntax highlighting. ### Methods #### `load_from_str(s: &str, lines_include_newline: bool, fallback_name: Option<&str>) -> Result` Loads a `SyntaxDefinition` from a string. - **s** (str) - The string containing the syntax definition. - **lines_include_newline** (bool) - Whether lines in the input string include a newline character. - **fallback_name** (Option<&str>) - An optional fallback name for the syntax definition. ### Traits Implemented - `Clone`: Allows creating a copy of a `SyntaxDefinition`. - `Eq`, `PartialEq`: Enables equality comparisons between `SyntaxDefinition` instances. - `Debug`: Allows for debugging output of `SyntaxDefinition` instances. - `Serialize`: Enables serialization of `SyntaxDefinition` instances (e.g., to JSON). - `Deserialize`: Enables deserialization of `SyntaxDefinition` instances. - `Freeze`, `Send`, `Sync`, `Unpin`, `RefUnwindSafe`, `UnwindSafe`: Indicate thread safety and memory safety properties. ``` -------------------------------- ### ThemeSet API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Provides methods for creating, loading, and managing syntax highlighting themes. ```APIDOC ## ThemeSet API ### Description Manages a collection of syntax highlighting themes. ### Methods - **`new()`**: Creates a new, empty `ThemeSet`. - **`load_defaults()`**: Loads the default themes provided by syntect. - **`load_from_folder>(folder: P)`**: Loads themes from a specified folder. - **`discover_theme_paths>(folder: P)`**: Discovers theme file paths within a folder. - **`get_theme>(path: P)`**: Loads a single theme from a file path. - **`add_from_folder>(&mut self, folder: P)`**: Adds themes from a folder to the existing `ThemeSet`. - **`load_from_reader(r: &mut R)`**: Loads a theme from a reader. ### Fields - **`themes`**: A `BTreeMap` mapping theme names (String) to `Theme` objects. ``` -------------------------------- ### ScopeRepository API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the syntect::parsing::ScopeRepository struct, including methods for retrieving atom strings, building scopes, converting scopes to strings, and formatting. ```APIDOC ## syntect::parsing::ScopeRepository ### Description Manages a repository of scopes, allowing for efficient lookup and conversion. ### Methods - **atom_str(&self, atom_number: u16) -> &str**: Gets the string representation of an atom number. - **build(&mut self, s: &str) -> Result**: Builds a Scope from a string. - **to_string(&self, scope: syntect::parsing::Scope) -> alloc::string::String**: Converts a Scope to its string representation. - **fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result**: Formats the ScopeRepository for debugging. ### Traits Implemented - `core::fmt::Debug` ``` -------------------------------- ### Syntect Easy HighlightLines API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Provides functionality for highlighting individual lines of text. ```APIDOC ## HighlightLines::new ### Description Creates a new `HighlightLines` instance for a given syntax and theme. ### Method `HighlightLines::new` ### Parameters - `syntax` (*&syntect::parsing::SyntaxReference*): The syntax reference to use. - `theme` (*&'a syntect::highlighting::Theme*): The theme to use. ### Returns - `syntect::easy::HighlightLines<'a>`: A new `HighlightLines` instance. ## HighlightLines::from_state ### Description Creates a new `HighlightLines` instance from existing highlight and parse states. ### Method `HighlightLines::from_state` ### Parameters - `theme` (*&'a syntect::highlighting::Theme*): The theme to use. - `highlight_state`: The highlight state. - `parse_state`: The parse state. ### Returns - `syntect::easy::HighlightLines<'a>`: A new `HighlightLines` instance. ## HighlightLines::highlight ### Description Highlights a single line of text and returns the styled ranges. ### Method `HighlightLines::highlight` ### Parameters - `line` (*&'b str*): The line of text to highlight. - `syntax_set` (*&syntect::parsing::SyntaxSet*): The syntax set to use. ### Returns - `alloc::vec::Vec<(syntect::highlighting::Style, &'b str)>`: A vector of styled string slices. ## HighlightLines::highlight_line ### Description Highlights a single line of text and returns the styled ranges, with error handling. ### Method `HighlightLines::highlight_line` ### Parameters - `line` (*&'b str*): The line of text to highlight. - `syntax_set` (*&syntect::parsing::SyntaxSet*): The syntax set to use. ### Returns - `core::result::Result, syntect::Error>`: A result containing the styled ranges or a `syntect::Error`. ## HighlightLines::state ### Description Returns the current highlight and parse states. ### Method `HighlightLines::state` ### Returns - `(syntect::highlighting::HighlightState, syntect::parsing::ParseState)`: A tuple containing the highlight and parse states. ``` -------------------------------- ### Scope Representation Ideas Source: https://github.com/trishume/syntect/blob/master/DESIGN.md Discusses different methods for representing scopes, including arrays of strings, atoms, and packed u64s, highlighting trade-offs in performance and complexity. ```plaintext - Normal arrays of strings - array of 32-bit or 64-bit atoms (maybe using Servo's atom library) - Atoms packed into one or two u64s - fast equality checking - potentially fast prefix checking - needs unsafe code ``` ```plaintext - variable width atoms, either 7 bits and a tag bit for top 128 or 13 bits and 3 tagging bits for rest - can fit all but 33 of the scopes present - tagged pointer (taking advantage of alignment), either a pointer to a slow path, or the first 4 bits set then a packed representation, one of others mentioned - 6 10-bit atoms referencing unique things by position (see by-position stats below) - 5 11-bit atoms and one 8-bit one for the first atom (2^11 = 2048, 2^8 = 256), one remaining bit for tag marker ``` -------------------------------- ### Syntect Dumps API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt APIs for serializing and deserializing data using syntect's binary dump format. ```APIDOC ## Dump Binary ### Description Serializes a given value into a binary vector. ### Method `dump_binary` ### Parameters - `o` (*T*): The value to serialize. Must implement `serde_core::ser::Serialize`. ### Returns - `alloc::vec::Vec`: A vector of bytes representing the serialized data. ## Dump to File ### Description Serializes a given value and writes it to a file. ### Method `dump_to_file` ### Parameters - `o` (*T*): The value to serialize. Must implement `serde_core::ser::Serialize`. - `path` (*P*): The path to the file. Must implement `core::convert::AsRef`. ### Returns - `core::result::Result<(), syntect::dumps::DumpError>`: Ok if successful, or a `DumpError` if an error occurs. ## Dump to Uncompressed File ### Description Serializes a given value and writes it to a file without compression. ### Method `dump_to_uncompressed_file` ### Parameters - `o` (*T*): The value to serialize. Must implement `serde_core::ser::Serialize`. - `path` (*P*): The path to the file. Must implement `core::convert::AsRef`. ### Returns - `core::result::Result<(), syntect::dumps::DumpError>`: Ok if successful, or a `DumpError` if an error occurs. ## Dump to Writer ### Description Serializes a given value and writes it to a writer. ### Method `dump_to_writer` ### Parameters - `to_dump` (*T*): The value to serialize. Must implement `serde_core::ser::Serialize`. - `output` (*W*): The writer to write to. Must implement `std::io::Write`. ### Returns - `core::result::Result<(), syntect::dumps::DumpError>`: Ok if successful, or a `DumpError` if an error occurs. ## From Binary ### Description Deserializes a value from a binary vector. ### Method `from_binary` ### Parameters - `v` (*&[u8]*): The byte slice to deserialize from. ### Returns - `T`: The deserialized value. Must implement `serde_core::de::DeserializeOwned`. ## From Dump File ### Description Deserializes a value from a dump file. ### Method `from_dump_file` ### Parameters - `path` (*P*): The path to the dump file. Must implement `core::convert::AsRef`. ### Returns - `core::result::Result`: The deserialized value or a `DumpError`. ## From Reader ### Description Deserializes a value from a reader. ### Method `from_reader` ### Parameters - `input` (*R*): The reader to deserialize from. Must implement `std::io::BufRead`. ### Returns - `core::result::Result`: The deserialized value or a `DumpError`. ## From Uncompressed Data ### Description Deserializes a value from uncompressed data. ### Method `from_uncompressed_data` ### Parameters - `v` (*&[u8]*): The byte slice containing the uncompressed data. ### Returns - `core::result::Result`: The deserialized value or a `DumpError`. ## From Uncompressed Dump File ### Description Deserializes a value from an uncompressed dump file. ### Method `from_uncompressed_dump_file` ### Parameters - `path` (*P*): The path to the uncompressed dump file. Must implement `core::convert::AsRef`. ### Returns - `core::result::Result`: The deserialized value or a `DumpError`. ``` -------------------------------- ### Syntect Color Type Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the syntect::highlighting::Color type, including its parsing from string and its serialization/deserialization capabilities. ```APIDOC ## syntect::highlighting::Color ### Description Represents a color value, with support for parsing from a string and serialization/deserialization using serde. ### Methods #### `from_str(s: &str) -> core::result::Result` Parses a string slice into a `Color`. ### Traits Implemented - `serde_core::ser::Serialize` - `serde_core::de::Deserialize` ``` -------------------------------- ### syntect::parsing::syntax_definition::ContextId Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the ContextId struct, detailing its methods and trait implementations. ```APIDOC ## struct syntect::parsing::syntax_definition::ContextId ### Description Represents an identifier for a context. ### Methods - `clone(&self) -> syntect::parsing::syntax_definition::ContextId`: Clones the ContextId. - `eq(&self, other: &syntect::parsing::syntax_definition::ContextId) -> bool`: Compares two ContextIds for equality. - `fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result`: Formats the ContextId for display. - `hash<__H: core::hash::Hasher>(&self, state: &mut __H)`: Hashes the ContextId. ### Trait Implementations - `core::clone::Clone`: Allows cloning the ContextId. - `core::cmp::Eq`: Provides equality comparison. - `core::cmp::PartialEq`: Provides partial equality comparison. - `core::fmt::Debug`: Allows formatting the ContextId for debugging. - `core::hash::Hash`: Enables hashing the ContextId. - `core::marker::Copy`: Indicates the type is copyable. - `core::marker::StructuralPartialEq`: Provides structural partial equality. - `serde_core::ser::Serialize`: Enables serialization of the ContextId. - `serde_core::de::Deserialize`: Enables deserialization of the ContextId. - `core::marker::Freeze`: Indicates the type is freeze. - `core::marker::Send`: Indicates the type is send. - `core::marker::Sync`: Indicates the type is sync. - `core::marker::Unpin`: Indicates the type is unpin. - `core::panic::unwind_safe::RefUnwindSafe`: Indicates the type is ref unwind safe. - `core::panic::unwind_safe::UnwindSafe`: Indicates the type is unwind safe. ``` -------------------------------- ### syntect::parsing::MatchPower Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the MatchPower struct, including its field and implemented traits. ```APIDOC ## syntect::parsing::MatchPower ### Description Represents the power of a syntax match, typically a floating-point value. ### Fields - `0`: `f64` (The match power value) ### Implementations - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::Ord` - `core::cmp::PartialEq` - `core::cmp::PartialOrd` - `core::fmt::Debug` ### Methods - `clone(&self) -> syntect::parsing::MatchPower` - `cmp(&self, other: &Self) -> core::cmp::Ordering` - `eq(&self, other: &syntect::parsing::MatchPower) -> bool` - `partial_cmp(&self, other: &syntect::parsing::MatchPower) -> core::option::Option` - `fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result` ``` -------------------------------- ### Scope API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the syntect::parsing::Scope struct, covering its methods for atom manipulation, string building, emptiness checks, prefix checks, length retrieval, creation, cloning, comparison, default values, formatting, hashing, and parsing. ```APIDOC ## syntect::parsing::Scope ### Description Represents a scope, often used in syntax highlighting. ### Methods - **atom_at(self, index: usize) -> u16**: Gets the atom at a given index. - **build_string(self) -> alloc::string::String**: Builds a string representation of the scope. - **is_empty(self) -> bool**: Checks if the scope is empty. - **is_prefix_of(self, s: syntect::parsing::Scope) -> bool**: Checks if this scope is a prefix of another scope. - **len(self) -> u32**: Returns the length of the scope. - **new(s: &str) -> Result**: Creates a new Scope from a string. - **clone(&self) -> syntect::parsing::Scope**: Clones the Scope. - **cmp(&self, other: &syntect::parsing::Scope) -> core::cmp::Ordering**: Compares two Scopes. - **eq(&self, other: &syntect::parsing::Scope) -> bool**: Compares two Scopes for equality. - **partial_cmp(&self, other: &syntect::parsing::Scope) -> Option**: Partially compares two Scopes. - **default() -> syntect::parsing::Scope**: Returns the default Scope. - **fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result**: Formats the Scope for debugging or display. - **hash<__H: core::hash::Hasher>(&self, state: &mut __H)**: Hashes the Scope. - **from_str(s: &str) -> Result**: Parses a string into a Scope. - **serialize(&self, serializer: S) -> Result<::Ok, ::Error> where S: serde_core::ser::Serializer**: Serializes the Scope. - **deserialize(deserializer: D) -> Result::Error> where D: serde_core::de::Deserializer<'de>**: Deserializes the Scope. ### Traits Implemented - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::Ord` - `core::cmp::PartialEq` - `core::cmp::PartialOrd` - `core::default::Default` - `core::fmt::Debug` - `core::fmt::Display` - `core::hash::Hash` - `core::marker::Copy` - `core::marker::StructuralPartialEq` - `core::str::traits::FromStr` - `serde_core::ser::Serialize` - `serde_core::de::Deserialize` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ``` -------------------------------- ### Prefix Checking Logic Source: https://github.com/trishume/syntect/blob/master/DESIGN.md Illustrates the bitwise operations for checking if a potential prefix matches a given scope, using XOR and bit manipulation. ```bash XXXXYYYY00000000 # prefix XXXXYYYYZZZZ0000 # testee 00000000ZZZZ0000 # = xored ``` ```bash XXXXYYYYQQQQ0000 # non-prefix XXXXYYYYZZZZ0000 # testee 00000000GGGG0000 # = xored ``` ```bash XXXXQQQQ00000000 # non-prefix XXXXYYYYZZZZ0000 # testee 0000BBBBZZZZ0000 # = xored ``` -------------------------------- ### Context Structure and Operations Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Details on the Context structure, its fields, and associated methods. ```APIDOC ## Context Structure ### Description Represents a context within a syntax definition, containing patterns and scope information. ### Fields - `clear_scopes`: `core::option::Option` - `meta_content_scope`: `alloc::vec::Vec` - `meta_include_prototype`: `core::option::Option` - `meta_scope`: `alloc::vec::Vec` - `patterns`: `alloc::vec::Vec` - `prototype`: `core::option::Option` - `uses_backrefs`: `bool` ### Methods - `new(meta_include_prototype: core::option::Option) -> syntect::parsing::syntax_definition::Context` Creates a new `Context` with the specified `meta_include_prototype` setting. - `match_at(&self, index: usize) -> core::result::Result<&syntect::parsing::syntax_definition::MatchPattern, syntect::parsing::ParsingError>` Attempts to match a pattern at the given index within the context. - `clone(&self) -> syntect::parsing::syntax_definition::Context` Creates a clone of the `Context`. ### Traits Implemented - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::PartialEq` ``` -------------------------------- ### ThemeSettings Structure Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Defines the customizable settings for a syntax highlighting theme. ```APIDOC ## ThemeSettings Structure ### Description Represents the configurable properties of a syntax highlighting theme, such as colors for different UI elements and text styles. ### Fields - **`background`** (Option) - The background color of the editor. - **`foreground`** (Option) - The default foreground color for text. - **`caret`** (Option) - The color of the text cursor. - **`line_highlight`** (Option) - The color to highlight the current line. - **`selection`** (Option) - The background color for selected text. - **`inactive_selection`** (Option) - The background color for inactive selection. - **`inactive_selection_foreground`** (Option) - The foreground color for inactive selection. - **`find_highlight`** (Option) - The background color for search result highlights. - **`find_highlight_foreground`** (Option) - The foreground color for search result highlights. - **`hover_highlight`** (Option) - The background color for hover highlights. - **`accent_color`** (Option) - An accent color used for various UI elements. - **`guide_color`** (Option) - The color of indentation guides. - **`active_guide_color`** (Option) - The color of the active indentation guide. - **`stack_guide_color`** (Option) - The color of the stack guide. - **`gutter_background`** (Option) - The background color of the line number gutter. - **`gutter_foreground`** (Option) - The foreground color of the line number gutter. - **`brackets_foreground`** (Option) - The foreground color for matching brackets. - **`brackets_options`** (Option) - Options for styling brackets. - **`bracket_contents_foreground`** (Option) - The foreground color for bracket contents. - **`bracket_contents_options`** (Option) - Options for styling bracket contents. - **`minimap_border`** (Option) - The color of the minimap border. - **`selection_foreground`** (Option) - The foreground color for selected text. ``` -------------------------------- ### MatchPower Marker Implementations Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Details the marker trait implementations for syntect::parsing::MatchPower. ```APIDOC ## syntect::parsing::MatchPower Marker Implementations ### Description Provides implementations for various marker traits for the `MatchPower` type, indicating its safety and capabilities. ### Implemented Traits - `core::marker::Copy` - `core::marker::StructuralPartialEq` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ``` -------------------------------- ### Region API Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the syntect::parsing::Region struct, including its methods for creation, position retrieval, cloning, comparison, default values, and debugging. ```APIDOC ## syntect::parsing::Region ### Description Represents a region with a start and end position. ### Methods - **new() -> Self**: Creates a new Region. - **pos(&self, index: usize) -> Option<(usize, usize)>**: Gets the position at a given index. - **clone(&self) -> syntect::parsing::Region**: Clones the Region. - **eq(&self, other: &syntect::parsing::Region) -> bool**: Compares two Regions for equality. - **default() -> Self**: Returns the default Region. - **fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result**: Formats the Region for debugging. ### Traits Implemented - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::PartialEq` - `core::default::Default` - `core::fmt::Debug` - `core::marker::StructuralPartialEq` - `core::marker::Freeze` - `!core::marker::Send` - `!core::marker::Sync` - `core::marker::Unpin` ``` -------------------------------- ### syntect::parsing::ScopeStackOp Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Documentation for the ScopeStackOp enum, detailing its variants and implemented traits. ```APIDOC ## syntect::parsing::ScopeStackOp ### Description An enum representing operations on the scope stack. ### Variants - `Clear(syntect::parsing::ClearAmount)` - `Noop` - `Pop(usize)` - `Push(syntect::parsing::Scope)` - `Restore` ### Implementations - `core::clone::Clone` - `core::cmp::Eq` - `core::cmp::PartialEq` - `core::fmt::Debug` - `core::marker::StructuralPartialEq` - `core::marker::Freeze` - `core::marker::Send` - `core::marker::Sync` - `core::marker::Unpin` - `core::panic::unwind_safe::RefUnwindSafe` - `core::panic::unwind_safe::UnwindSafe` ### Methods - `clone(&self) -> syntect::parsing::ScopeStackOp` - `eq(&self, other: &syntect::parsing::ScopeStackOp) -> bool` - `fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result` ``` -------------------------------- ### SyntaxSet - Syntax Finding Methods Source: https://github.com/trishume/syntect/blob/master/tests/snapshots/public-api.txt Details the methods available on the `SyntaxSet` struct for finding syntax references. ```APIDOC ## `syntect::parsing::SyntaxSet` ### Description Manages a collection of syntax definitions and provides methods to find them. ### Methods #### `find_syntax_by_extension<'a>(&'a self, extension: &str) -> Option<&'a SyntaxReference>` Finds a `SyntaxReference` by its file extension. - **extension** (&str) - The file extension to search for. #### `find_syntax_by_first_line<'a>(&'a self, s: &str) -> Option<&'a SyntaxReference>` Finds a `SyntaxReference` by matching against the first line of a file. - **s** (&str) - The content of the first line. #### `find_syntax_by_name<'a>(&'a self, name: &str) -> Option<&'a SyntaxReference>` Finds a `SyntaxReference` by its name. - **name** (&str) - The name of the syntax to search for. #### `find_syntax_by_path<'a>(&'a self, path: &str) -> Option<&'a SyntaxReference>` Finds a `SyntaxReference` by its file path. - **path** (&str) - The file path to search with. ```