type_bridge.generator.annotations¶
annotations
¶
Annotation parsing for TQL schema comments.
Annotations use TypeDB's syntax: @name -> boolean True @name(value) -> parsed value (int, float, bool, or string) @name(a, b, c) -> list of values
parse_annotation_value
¶
Parse a single annotation value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
str
|
Raw value string (may be quoted, numeric, or boolean) |
required |
Returns:
| Type | Description |
|---|---|
AnnotationScalar
|
Parsed value as int, float, bool, or str |
Source code in type_bridge/generator/annotations.py
parse_annotation
¶
Parse a single annotation from a comment line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
A line that may contain an annotation comment |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, AnnotationValue] | None
|
Tuple of (name, value) if annotation found, None otherwise |
Examples:
"# @searchable" -> ("searchable", True) "# @prefix(PROJ)" -> ("prefix", "PROJ") "# @priority(3)" -> ("priority", 3) "# @enabled(true)" -> ("enabled", True) "# @tags(api, public)" -> ("tags", ["api", "public"])
Source code in type_bridge/generator/annotations.py
extract_annotations
¶
Extract all annotations from a TQL schema.
Pre-processes the schema text to find annotation comments and associate them with the definitions that follow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_text
|
str
|
The full TQL schema text |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, AnnotationValue]]
|
Four dicts mapping definition names to their annotation dicts: |
dict[str, dict[str, AnnotationValue]]
|
|
dict[str, dict[str, AnnotationValue]]
|
|
dict[str, dict[str, dict[str, AnnotationValue]]]
|
|
tuple[dict[str, dict[str, AnnotationValue]], dict[str, dict[str, AnnotationValue]], dict[str, dict[str, AnnotationValue]], dict[str, dict[str, dict[str, AnnotationValue]]]]
|
|
Source code in type_bridge/generator/annotations.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
Parses TypeDB-style annotations from comments like
@prefix(PROJ)¶
@searchable¶
@tags(api, public)¶
entity project;