Skip to content

Commit

Permalink
preprocessor: use the language of "text" for .cue files
Browse files Browse the repository at this point in the history
This is until we land syntax highlighting support for CUE. Without this
change, setting line numbers in a CUE code block does not work.

Preprocessor-No-Write-Cache: true
Signed-off-by: Paul Jolly <[email protected]>
Change-Id: Ifc39b45caf2156b8b1b8673bb9b1291f0c6c0301
Dispatch-Trailer: {"type":"trybot","CL":1169622,"patchset":3,"ref":"refs/changes/22/1169622/3","targetBranch":"alpha"}
  • Loading branch information
myitcv authored and cueckoo committed Sep 19, 2023
1 parent 0753906 commit f3b7cf2
Show file tree
Hide file tree
Showing 25 changed files with 133 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Create a CUE file named `x.cue`
The following CUE creates a CUE definition that describes the data type
constraints for every person.

```cue { title="x.cue" }
```text { title="x.cue" }
#Person: {
name: string
age: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ JSON does not natively support binary data.
When exporting to JSON, CUE translates it to base64.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: #’A newline is written as \n.’#
b: '''
sfsf
Expand All @@ -33,7 +33,7 @@ b: '''
CUE translates bytes to the corresponding YAML binary type.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: #’A newline is written as \n.’#
b: '''
sfsf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configurations in general:
- the outermost curly braces are optional. {{{TODO "note on embedding"}}}

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
// A doc comment
map: {
member1: 3 // a line comment
Expand All @@ -40,7 +40,7 @@ map: {
CUE supports `//`-style comments. Comments are first-class citizens in CUE.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
// A doc comment
map: {
member1: 3 // a line comment
Expand Down
4 changes: 2 additions & 2 deletions hugo/content/en/docs/language-guide/data/lists/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ List elements are considered to be a special kind of data field, with elements
indexed by their position.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: [1, 2]
"a": [1, 2, 3]
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
a: [1, 2, 3]
{{< /code-tab >}}
{{< /code-tabs >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Identifiers may also start with `#` or `_`, in which case the field is a
special meaning.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a1: 1
"a-b": 2 // quotes are needed here
$id: "yipee"
Expand All @@ -41,11 +41,11 @@ Names of regular fields are considered equal if their string values are equal,
regardless of whether the strings are quoted or not.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: x: 1
"a": y: 2
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
a: {
x: 1
y: 2
Expand Down Expand Up @@ -76,7 +76,7 @@ More on this in the
[Templating](Templating%20f4e21af73d744a77aa2c91203a8dbe4f.md) section.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
one: {
value: 1
#typeName: "int"
Expand All @@ -103,7 +103,7 @@ It is possible to associate helper fields with scalar types by placing both in
curly braces (`{}`).

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
one: {
1
#typeName: "int"
Expand All @@ -117,7 +117,7 @@ three: {
#typeName: "map"
}
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
one: {
1
#typeName: "int"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gets rounded down to the nearest whole number.
Note that `k` is written as `K` instead.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: 1_000_000
b: 1M
c: 1Mi
Expand All @@ -54,7 +54,7 @@ CUE can represent numbers in bases other than decimal.
| Binary | 0b | 0b1111_1111 | 255 |

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
o: 0o755
h: 0x00Dec0de
b: 0b0101_0001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ CUE allows duplicate fields to exist as long as their values are consistent.
This is allowed:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: 1
a: 1
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
a: 1
{{< /code-tab >}}
{{< /code-tabs >}}

This is not:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
b: 1
b: 2
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
b: conflicting values 2 and 1:
in.cue: 1:4
in.cue: 2:4
Expand All @@ -46,7 +46,7 @@ Two maps or lists are consistent if the values with the same key or index are
consistent.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
point: {
x: 1
}
Expand All @@ -59,7 +59,7 @@ point: {

list: [1, 2, 3, 4]
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
point: {
x: 1
y: 2
Expand All @@ -79,11 +79,11 @@ More on this in [Schemas and Validation](Schemas%20and%20Validation%20b39455d56f
For single-field maps, the curly braces can be omitted:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
point2: x: 1
point2: y: 2
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
point2: {
x: 1
y: 2
Expand All @@ -94,10 +94,10 @@ point2: {
One can also combine values with the `&` operator:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
point3: {x: 1} & {y: 2}
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
point3: {
x: 1
y: 2
Expand All @@ -120,20 +120,20 @@ makes it easier to separate human written versus machine generated content,
among other things.

{{< code-tabs >}}
{{< code-tab name="fruit.cue" language="cue" area="top-left" >}}
{{< code-tab name="fruit.cue" language="text" area="top-left" >}}
package food

cart: {
apples: 1
oranges: 3
}
{{< /code-tab >}}
{{< code-tab name="vegetables.cue" language="cue" area="bottom-left" >}}
{{< code-tab name="vegetables.cue" language="text" area="bottom-left" >}}
package food

cart: spinach: 4
{{< /code-tab >}}
{{< code-tab name="TERMINAL" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="TERMINAL" language="text" type="terminal" area="top-right" >}}
cart: {
apples: 1
oranges: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The whitespace preceding the last `"""` must prefix each non-empty line of the
string contents and is stripped from all lines.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
msg: """
Hello World!

Expand Down Expand Up @@ -69,7 +69,7 @@ single pair of hashes uses `\#` as the escape character, instead of `\`. A
string enclosed in two hashes uses `\##`, and so on.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: #"A newline is\#nwritten as "\n"."#

b: ##"Use \#n to write a newline in that case.”##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ You can write `[a, b, ...]` to allow more items.
or closed, map or list.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
c: close({a: 1})

a: c & {b: 2}
Expand All @@ -64,7 +64,7 @@ This circumvents the usual limitation that no new fields can be added to a
definition.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
#Base: {}
#Animal: {
kind!: string
Expand All @@ -80,7 +80,7 @@ definition.
house: string
}
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
#Base: {}
#Animal: {
kind!: string
Expand Down Expand Up @@ -114,10 +114,10 @@ Schemas are often composed of other schemas. You can embed schemas in another to
extend them:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}

{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}

{{< /code-tab >}}
{{< /code-tabs >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Schema can compose with data, for instance to validate data.
For instance, this is valid:

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: 1
a?: int
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
a: 1
{{< /code-tab >}}
{{< /code-tabs >}}

This is not

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: 1
a?: string
{{< /code-tab >}}
Expand All @@ -35,10 +35,10 @@ It is also possible to combine schemas. For instance, the following CUE defines
restrictions on what values are allowed for another schema.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}

{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}

{{< /code-tab >}}
{{< /code-tabs >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ or([]) _|_
```

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
a: or([1, 2, 3, 4, 5])
b: or([2])
c: or(empty)
Expand All @@ -40,7 +40,7 @@ empty: []
withDefault: *2 | or([1, 2, 3, 4])
x: withDefault & 3
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
a: 1 | 2 | 3 | 4 | 5
b: 2
c: or(empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ without actually declaring these fields. Since in CUE data and schema is mixed,
we explicitly mark schema fields with a question mark (`?`):

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
Feedback: {
all?: string
committee?: string
}
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
Feedback: {}
{{< /code-tab >}}
{{< /code-tabs >}}
Expand All @@ -43,14 +43,14 @@ We use `!` instead of `?` to additionally specify that this field _*must_* be
defined for an instance of this map to be valid.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
{{< code-tab name="CUE" language="text" area="top-left" >}}
Name: {
first!: string
middle?: string
last!: string
}
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" type="terminal" area="top-right" >}}
{{< code-tab name="CUE" language="text" type="terminal" area="top-right" >}}
Name: {
first!: string
last!: string
Expand Down
Loading

0 comments on commit f3b7cf2

Please sign in to comment.