@malloydata/malloy-tag 0.0.324 → 0.0.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +99 -0
- package/package.json +1 -1
package/CONTEXT.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Malloy Tag Language
|
|
2
|
+
|
|
3
|
+
The Malloy Tag Language is a concise, readable syntax for adding structured metadata to Malloy objects through annotations. It's designed to work seamlessly with Malloy's annotation system.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
While Malloy annotations can contain arbitrary text, the Tag Language provides a standardized way to express structured metadata that is:
|
|
8
|
+
- Human-readable and writable
|
|
9
|
+
- Easy to parse programmatically
|
|
10
|
+
- Flexible enough for various use cases
|
|
11
|
+
- Concise and unobtrusive in code
|
|
12
|
+
|
|
13
|
+
## Syntax Overview
|
|
14
|
+
|
|
15
|
+
The Tag Language supports several data types:
|
|
16
|
+
|
|
17
|
+
### Boolean Tags
|
|
18
|
+
```malloy
|
|
19
|
+
# hidden
|
|
20
|
+
```
|
|
21
|
+
A tag name without a value is a boolean (implicitly `true`).
|
|
22
|
+
|
|
23
|
+
### String Values
|
|
24
|
+
```malloy
|
|
25
|
+
# color=blue
|
|
26
|
+
# name="User Name"
|
|
27
|
+
```
|
|
28
|
+
Unquoted strings for simple values, quoted strings for values with spaces or special characters.
|
|
29
|
+
|
|
30
|
+
### Numeric Values
|
|
31
|
+
```malloy
|
|
32
|
+
# size=10
|
|
33
|
+
# width=100.5
|
|
34
|
+
```
|
|
35
|
+
Numbers are automatically parsed as numeric types.
|
|
36
|
+
|
|
37
|
+
### Nested Properties
|
|
38
|
+
```malloy
|
|
39
|
+
# box { width=100 height=200 }
|
|
40
|
+
```
|
|
41
|
+
Curly braces create nested property groups.
|
|
42
|
+
|
|
43
|
+
### Combined Example
|
|
44
|
+
```malloy
|
|
45
|
+
#(myApp) hidden color=blue size=10 box { width=100 height=200 } name="Blue Thing"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Annotation Prefixes
|
|
49
|
+
|
|
50
|
+
Different prefixes are used to avoid collision between different uses of annotations:
|
|
51
|
+
|
|
52
|
+
- **`# `** (hash-space) - Reserved for Malloy renderer
|
|
53
|
+
- **`#!`** - Compiler directives
|
|
54
|
+
- **`#(docs)`** - Malloy documentation
|
|
55
|
+
- **`#(appName) `** - Encouraged pattern for application-specific tags
|
|
56
|
+
|
|
57
|
+
Example with application prefix:
|
|
58
|
+
```malloy
|
|
59
|
+
#(myApp) visible theme=dark priority=high
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Multi-line Annotations
|
|
63
|
+
|
|
64
|
+
The tag language works with single-line annotations. For multi-line text that is NOT in the tag language:
|
|
65
|
+
|
|
66
|
+
```malloy
|
|
67
|
+
#" This is a multi-line string annotation
|
|
68
|
+
#" which is NOT in the tag language
|
|
69
|
+
#" but could be displayed as help text
|
|
70
|
+
source: name is VALUE
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage Pattern
|
|
74
|
+
|
|
75
|
+
The expected workflow for using tag annotations:
|
|
76
|
+
|
|
77
|
+
1. **Write annotations** in Malloy code using tag syntax
|
|
78
|
+
2. **Query annotations** from compiled model using pattern matching (filter by prefix)
|
|
79
|
+
3. **Parse tags** using the malloy-tag package
|
|
80
|
+
4. **Extract values** and use in your application
|
|
81
|
+
|
|
82
|
+
## Implementation
|
|
83
|
+
|
|
84
|
+
The `malloy-tag` package provides:
|
|
85
|
+
- **Parser** for tag language syntax
|
|
86
|
+
- **Type definitions** for parsed tag structures
|
|
87
|
+
- **Utilities** for working with tags in JavaScript/TypeScript
|
|
88
|
+
|
|
89
|
+
## Documentation
|
|
90
|
+
|
|
91
|
+
For complete tag language syntax and examples, see:
|
|
92
|
+
https://docs.malloydata.dev/documentation/language/tags
|
|
93
|
+
|
|
94
|
+
## Important Notes
|
|
95
|
+
|
|
96
|
+
- Not all annotations use the tag language - raw text is also valid
|
|
97
|
+
- The tag language is optional - annotations can be simple strings
|
|
98
|
+
- Each application defines its own conventions for tag usage
|
|
99
|
+
- Tags are metadata only - they don't affect query execution
|