MCPcopy Create free account
hub / github.com/csskit/csskit / build_display

Method build_display

crates/csskit/src/commands/tree.rs:47–77  ·  view source on GitHub ↗
(&self, query: &VisitNode)

Source from the content-addressed store, hash-verified

45 }
46
47 fn build_display(&self, query: &VisitNode) -> String {
48 let meta = query.self_metadata();
49 let meta = &meta;
50 let mut display = query.node_id.expect("tree output only displays queryable nodes").tag_name().to_string();
51
52 // Attributes
53 for &kind in PROPERTY_KIND_VARIANTS {
54 if !meta.property_kinds.contains(kind) {
55 continue;
56 }
57 if let Some(cursor) = query.property(kind) {
58 let value = self.cursor_to_str(cursor);
59 let attr_name = match kind {
60 PropertyKind::Name => "name",
61 _ => continue,
62 };
63 display.push_str(&format!("[{}={}]", attr_name, value));
64 }
65 }
66
67 // Pseudos
68 for name in QueryPseudoClass::matching_metadata_pseudos(meta) {
69 display.push(':');
70 display.push_str(name);
71 }
72 if let Some(size) = QueryFunctionalPseudoClass::matching_size(meta) {
73 display.push_str(&format!(":size({})", size));
74 }
75
76 display
77 }
78
79 fn cursor_to_str(&self, cursor: Cursor) -> &str {
80 let span = cursor.to_span();

Callers 1

enter_nodeMethod · 0.80

Calls 4

propertyMethod · 0.80
cursor_to_strMethod · 0.80
self_metadataMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected