Expand description
Strongly-typed AST types for CSS, auto-generated from
tree-sitter-css’s node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Bootstrap source code.
See the Tree-sitter project for more information about the underlying parser framework.
§Example
use treesitter_types_css::*;
// A small CSS stylesheet.
let src = b"\
body {
color: red;
font-size: 16px;
}
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_css::LANGUAGE.into()).unwrap();
let tree = parser.parse(src, None).unwrap();
let stylesheet = Stylesheet::from_node(tree.root_node(), src).unwrap();
// The stylesheet has one top-level child: a rule set for `body`.
assert_eq!(stylesheet.children.len(), 1);
let StylesheetChildren::RuleSet(rule_set) = &stylesheet.children[0] else {
panic!("expected a rule set");
};
// The rule set contains the selector and declarations.
assert!(!rule_set.children.is_empty());
assert_eq!(rule_set.span.start.row, 0);Re-exports§
pub use tree_sitter_css;pub use treesitter_types::tree_sitter;
Structs§
- Adjacent
Sibling Selector - Arguments
- AtKeyword
- AtRule
- Attribute
Name - Attribute
Selector - Binary
Expression - Binary
Query - Block
- Call
Expression - Charset
Statement - Child
Selector - Class
Name - Class
Selector - Color
Value - Comment
- Declaration
- Descendant
Selector - Escape
Sequence - Feature
Name - Feature
Query - Float
Value - From
- Function
Name - Grid
Value - IdName
- IdSelector
- Identifier
- Import
Statement - Important
- Important
Value - Integer
Value - JsComment
- Keyframe
Block - Keyframe
Block List - Keyframes
Name - Keyframes
Statement - Keyword
Query - Media
Statement - Namespace
Name - Namespace
Selector - Namespace
Statement - Nesting
Selector - Parenthesized
Query - Parenthesized
Value - Plain
Value - Postcss
Statement - Property
Name - Pseudo
Class Selector - Pseudo
Element Selector - RuleSet
- Scope
Statement - Selector
Query - Selectors
- Sibling
Selector - Span
- String
Content - String
Value - Stylesheet
- Supports
Statement - TagName
- To
- Unary
Query - Unit
- Universal
Selector
Enums§
- Adjacent
Sibling Selector Children - AnyNode
- Arguments
Children - AtRule
Children - Attribute
Name Children - Attribute
Selector Children - Binary
Expression Children - Binary
Query Children - Block
Children - Call
Expression Children - Charset
Statement Children - Child
Selector Children - Class
Name Children - Class
Selector Children - Declaration
Children - Descendant
Selector Children - Feature
Query Children - Grid
Value Children - IdSelector
Children - Import
Statement Children - Keyframe
Block Children - Keyframes
Statement Children - Media
Statement Children - Namespace
Selector Children - Namespace
Statement Children - Parenthesized
Query Children - Parenthesized
Value Children - Parse
Error - Postcss
Statement Children - Pseudo
Class Selector Children - Pseudo
Element Selector Children - Rule
SetChildren - Scope
Statement Children - Selector
Query Children - Selectors
Children - Sibling
Selector Children - String
Value Children - Stylesheet
Children - Supports
Statement Children - Unary
Query Children