Skip to content

Commit

Permalink
docs/introduction: update welcome to use code directive
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Jolly <[email protected]>
Change-Id: I9eb41c16b47f67ea39ea5fb9392670422729cb53
Preview-Path: /docs/introduction/welcome/
  • Loading branch information
myitcv committed Sep 19, 2023
1 parent 0cd2ff8 commit 78447ce
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 58 deletions.
78 changes: 45 additions & 33 deletions content/docs/introduction/welcome/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,34 @@ On the right one sees a mix between data and schema as is exemplary of CUE.

{{< columns >}}
Data
```cue
{{{with code "en" "data"}}}
-- in.cue --
moscow: {
name: "Moscow"
pop:   11.92M
capital: true
name: "Moscow"
pop: 11.92M
capital: true
}
```
{{{end}}}
{{< columns-separator >}}
Schema
```cue
{{{with code "en" "schema"}}}
-- in.cue --
municipality: {
name: string
pop:   int
capital: bool
name: string
pop: int
capital: bool
}
```
{{{end}}}
{{< columns-separator >}}
CUE
```cue
{{{with code "en" "CUE"}}}
-- in.cue --
largeCapital: {
name: string
pop:   >5M
capital: true
name: string
pop: >5M
capital: true
}
```
{{{end}}}
{{< /columns >}}

In general, in CUE one starts with a broad definition of a type, describing
Expand All @@ -157,20 +160,24 @@ This selection can be at a different point in the configuration altogether.
Another way to view this, a JSON configuration, say, can be
defined as a sequence of path-leaf values.
For instance,
```json
{{{with code "en" "json"}}}
-- in.json --
{
"a": 3,
"b": {
"c": "foo"
}
"a": 3,
"b": {
"c": "foo"
}
}
```
{{{end}}}

could be represented as
```

{{{with code "en" "cue form of json"}}}
-- in.cue --
"a": 3
"b": "c": "foo"
```
{{{end}}}

All the information of the original JSON file is retained in this
representation.

Expand All @@ -196,24 +203,29 @@ Instead of having to spell this out at each point,
one can declare this separately in a one blanket statement.

So instead of
```

{{{with code "en" "non-dry"}}}
-- in.cue --
jobs: {
foo: acmeMonitoring & { /* ... */ }
bar: acmeMonitoring & { /* ... */ }
baz: acmeMonitoring & { /* ... */ }
foo: acmeMonitoring & {...}
bar: acmeMonitoring & {...}
baz: acmeMonitoring & {...}
}
```
{{{end}}}

one can write

```
{{{with code "en" "dry"}}}
-- in.cue --
jobs: [string]: acmeMonitoring

jobs: {
foo: { /* ... */ }
bar: { /* ... */ }
baz: { /* ... */ }
foo: {...}
bar: {...}
baz: {...}
}
```
{{{end}}}

There is no need to repeat the reference to the monitoring template for
each job, as the first already states that all jobs _must_ use `acmeMonitoring`.
Such requirements can be specified across files.
Expand Down
20 changes: 20 additions & 0 deletions content/docs/introduction/welcome/gen_cache.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package site
{
docs: {
introduction: {
welcome: {
cache: {
code: {
data: "rJdPKi32hmQolK+RPmHbwVJBSnMtKDXAlVCSkx7LI1g="
schema: "0g2xi4ZXjRAHEoRg1FdMxVj6S/MHhIdvLhFnKpD+Hp0="
CUE: "yQKwQlZmkf3hW2wtajdi6odhP5aCiY4pKYg4UkifEcM="
json: "1KFvsMuO4fqo4plV/7aE8Wo0JYMmHl5k06IIaWvAVaA="
"cue form of json": "z+kxIRELdoD9sBI31ZsH5pS4s02AN/50l1JjqOwhxeE="
"non-dry": "D2xO4AjqMj5xee1USbHrjRRNVjmvzny6K8E/zzTIdhM="
dry: "PBz50kTmem6cI5G5Zrv4LcLFc+NxuXYzcxZGhyd2ovM="
}
}
}
}
}
}
55 changes: 30 additions & 25 deletions hugo/content/en/docs/introduction/welcome/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,29 @@ On the right one sees a mix between data and schema as is exemplary of CUE.

{{< columns >}}
Data
```cue
```text
moscow: {
name: "Moscow"
pop:   11.92M
capital: true
name: "Moscow"
pop: 11.92M
capital: true
}
```
{{< columns-separator >}}
Schema
```cue
```text
municipality: {
name: string
pop:   int
capital: bool
name: string
pop: int
capital: bool
}
```
{{< columns-separator >}}
CUE
```cue
```text
largeCapital: {
name: string
pop:   >5M
capital: true
name: string
pop: >5M
capital: true
}
```
{{< /columns >}}
Expand Down Expand Up @@ -159,18 +159,20 @@ defined as a sequence of path-leaf values.
For instance,
```json
{
"a": 3,
"b": {
"c": "foo"
}
"a": 3,
"b": {
"c": "foo"
}
}
```

could be represented as
```

```text
"a": 3
"b": "c": "foo"
```

All the information of the original JSON file is retained in this
representation.

Expand All @@ -196,24 +198,27 @@ Instead of having to spell this out at each point,
one can declare this separately in a one blanket statement.

So instead of
```

```text
jobs: {
foo: acmeMonitoring & { /* ... */ }
bar: acmeMonitoring & { /* ... */ }
baz: acmeMonitoring & { /* ... */ }
foo: acmeMonitoring & {...}
bar: acmeMonitoring & {...}
baz: acmeMonitoring & {...}
}
```

one can write

```
```text
jobs: [string]: acmeMonitoring
jobs: {
foo: { /* ... */ }
bar: { /* ... */ }
baz: { /* ... */ }
foo: {...}
bar: {...}
baz: {...}
}
```

There is no need to repeat the reference to the monitoring template for
each job, as the first already states that all jobs _must_ use `acmeMonitoring`.
Such requirements can be specified across files.
Expand Down

0 comments on commit 78447ce

Please sign in to comment.