Skip to content

Commit

Permalink
update site to v0.10.0
Browse files Browse the repository at this point in the history
And enable rendering of the `cue help embed` page.

Note that a number of jsonschema files are imported differently,
and we are also more strict about the schema version strings too.
The other changes are varied, including some CUE formatting fixes
and some changes to help texts.

DO NOT MERGE: to update once v0.10.0 is tagged

Preprocessor-No-Write-Cache: true
Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I392c68336c800c95dba7eac695e64410b8f94bcc
Dispatch-Trailer: {"type":"trybot","CL":1199504,"patchset":2,"ref":"refs/changes/04/1199504/2","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Aug 14, 2024
1 parent 6ed8625 commit e9f8c25
Show file tree
Hide file tree
Showing 55 changed files with 267 additions and 138 deletions.
2 changes: 1 addition & 1 deletion content/docs/concept/cue-language-version/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ but in more recent CUE versions, this has been changed to:

{{{with code "en" "a2"}}}
-- in.cue --
let x = 5
let x = 5
{{{end}}}

If the language were never to be changed in a backwards incompatible
Expand Down
2 changes: 1 addition & 1 deletion content/docs/concept/how-cue-enables-data-validation/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ Let's include a JSON Schema file that adds some constraints to a couple of
{{{with upload "en" "schema.json"}}}
-- schema.json --
{
"$schema": "http://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ExampleType": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion content/docs/concept/how-cue-works-with-json-schema/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import "strings"
@jsonschema(schema="http://json-schema.org/draft-07/schema#")

// What is this person called?
name: strings.MinRunes(1)
name!: strings.MinRunes(1)

// Where does this person live?
address?: strings.MinRunes(1) & strings.MaxRunes(200)
Expand Down
4 changes: 2 additions & 2 deletions content/docs/concept/how-cue-works-with-openapi/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ info: {
// A Pet is a pet that we handle.
#Pet: {
// A pet has a name.
name: string
kind: #Kind
name!: string
kind!: #Kind

// Centenarian pets are not handled.
age?: int & >=0 & <100
Expand Down
4 changes: 2 additions & 2 deletions content/docs/howto/write-a-type-switch/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ output: [for v in input {
// Here, isANumber is implemented as a switch. Other, simpler,
// representations are also possible.
isANumber: [
if (v & number) != _|_ {true},
if (v & number) == _|_ {false},
if (v & number) != _|_ {true},
if (v & number) == _|_ {false},
][0]
}]
-- out --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ definition.
name?: string
}
#Mammal: {
#Base// embedded
#Base // embedded
lungCapacityL: number
}
#Dog: {
#Mammal// embedded
#Mammal // embedded
kind!: "dog"
house: string
}
Expand Down
8 changes: 4 additions & 4 deletions content/docs/language-guide/templating/comprehensions/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ CUE has no switch or if-else construct, but these can be simulated using lists.

{{{with code "en" "switch-if-else-pattern"}}}
-- in.cue --
mem: 2Gi
mem: 2Gi
footprint: [// select first
if mem < 1Gi {"small"},
if mem < 4Gi {"medium"},
"large",
if mem < 1Gi {"small"},
if mem < 4Gi {"medium"},
"large",
][0]
-- out.cue --
mem: 2147483648
Expand Down
2 changes: 1 addition & 1 deletion content/docs/language-guide/templating/references/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ merging two maps.
{{{with code "en" "let-expressions"}}}
#norun open lists not implemented yet
-- in.cue --
let X = {list: []}
let X = {list: []}
a: X
b: X
c: X
Expand Down
3 changes: 1 addition & 2 deletions content/docs/reference/command/commands.cue
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ cue: {
commands: _
completion: _
def: _
// TODO: once CUE v0.10.0 is out, include `cue help embed`.
// embed: _
embed: _
environment: _
eval: _
export: _
Expand Down
12 changes: 12 additions & 0 deletions content/docs/reference/command/cue-help-embed/en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
WARNING: "Code generated site_tool.cue; DO NOT EDIT."
title: "cue help embed"
aliases: ["/docs/reference/cli/cue-embed/"]
weight: 1000
tags:
- cue command
---

{{{with script "en" "cue cli help text"}}}
cue help embed
{{{end}}}
4 changes: 4 additions & 0 deletions content/docs/reference/command/cue-help-embed/page.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Code generated site_tool.cue; DO NOT EDIT.
package site

{"content":{"docs":{"reference":{"command":{"cue-help-embed":{"page":{}}}}}}}
7 changes: 6 additions & 1 deletion content/docs/reference/spec/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,12 @@ PackageClause = "package" PackageName .
PackageName = identifier .
```

The PackageName must not be the blank identifier or a definition identifier.
The PackageName must not be a definition identifier.

If the PackageName is the blank identifier (`_`), it is treated the same
as if there were no package clause. This can be useful to allow adding
package level attributes or doc comments to a CUE file without a package
name.

```
package math
Expand Down
10 changes: 5 additions & 5 deletions content/docs/tutorial/converting-json-schema-to-cue/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ package cuisine

#restaurant: {
@jsonschema(schema="http://json-schema.org/draft-07/schema#")
name: string
cuisine: string
tables: [...#table]
name!: string
cuisine!: string
tables!: [...#table]

#table: {
seats: >=2 & <=10
view?: bool
seats!: >=2 & <=10
view?: bool
}
}
{{{end}}}
Expand Down
4 changes: 2 additions & 2 deletions hugo/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ logo = "svg/logo.svg"
# Add a site-wide notification-bar
# Contents allows for markdown, leave out the button if you don't want a button
[notification]
type = 'cue-minor-release-v0.9'
type = 'cue-minor-release-v0.10'

content = '**CUE v0.9 is now available** -- learn more about its [new features and improvements](https://github.com/cue-lang/cue/releases/tag/v0.9.0)'
content = '**CUE v0.10 is now available** -- learn more about its [new features and improvements](https://github.com/cue-lang/cue/releases/tag/v0.10.0)'
[notification.button]
link = '/docs/introduction/installation/'
icon = 'download'
Expand Down
2 changes: 1 addition & 1 deletion hugo/content/en/docs/concept/cue-language-version/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ x = 5 // Don't use this old alias syntax!
but in more recent CUE versions, this has been changed to:

```cue
let x = 5
let x = 5
```

If the language were never to be changed in a backwards incompatible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Let's include a JSON Schema file that adds some constraints to a couple of
{{< code-tabs >}}
{{< code-tab name="schema.json" language="json" area="top-left" >}}
{
"$schema": "http://json-schema.org/draft-07/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ExampleType": {
"type": "object",
Expand Down
12 changes: 6 additions & 6 deletions hugo/content/en/docs/concept/how-cue-works-with-go/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func main() {

Before running, we add a dependency on the `cuelang.org/go` module and tidy:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down Expand Up @@ -237,8 +237,8 @@ age: 99
We finish by adding a dependency on the `cuelang.org/go` module, tidying,
and running the program:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQpnbyBydW4gLg==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQpnbyBydW4gLg==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down Expand Up @@ -312,8 +312,8 @@ func main() {

This time we see that CUE correctly caught a problem in our data:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQpnbyBydW4gLg==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQpnbyBydW4gLg==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import "strings"
@jsonschema(schema="http://json-schema.org/draft-07/schema#")

// What is this person called?
name: strings.MinRunes(1)
name!: strings.MinRunes(1)

// Where does this person live?
address?: strings.MinRunes(1) & strings.MaxRunes(200)
Expand Down Expand Up @@ -140,7 +140,7 @@ command validates our data against the `#Person` constraint:
$ cue vet -d '#Person' schema.cue good.json bad.json
name: conflicting values strings.MinRunes(1) and ["Charlie","Cartwright"] (mismatched types string and list):
./bad.json:2:13
./schema.cue:10:8
./schema.cue:10:9
```

The `cue vet` command can also validate the data using the JSON Schema directly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ info: {
// A Pet is a pet that we handle.
#Pet: {
// A pet has a name.
name: string
kind: #Kind
name!: string
kind!: #Kind

// Centenarian pets are not handled.
age?: int & >=0 & <100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This guide demonstrates the following version:

```text { title="TERMINAL" type="terminal" codeToCopy="Y3VlIHZlcnNpb24=" }
$ cue version
cue version v0.10.0-rc.1
cue version v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
```

Expand Down
4 changes: 2 additions & 2 deletions hugo/content/en/docs/howto/handle-errors-go-api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func main() {
{{< step stepNumber="6" >}}
Add a dependency on `cuelang.org/go` and ensure the Go module is tidy:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down
4 changes: 2 additions & 2 deletions hugo/content/en/docs/howto/validate-go-cuego/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ and prints the validation result for each instance.
{{< step stepNumber="3" >}}
Add a dependency on `cuelang.org/go` and ensure the Go module is tidy:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ single JSON file, printing the validation result to its standard output stream.

{{< step stepNumber="6" >}}
Add a dependency on `cuelang.org/go` and ensure the Go module is tidy:
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down
4 changes: 2 additions & 2 deletions hugo/content/en/docs/howto/walk-schemas-using-go-api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func structToType(name cue.Selector, val cue.Value) {
{{< step stepNumber="6" >}}
Add a dependency on `cuelang.org/go` and ensure the Go module is tidy:

```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjkuMgpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.9.2
```text { title="TERMINAL" type="terminal" codeToCopy="Z28gZ2V0IGN1ZWxhbmcub3JnL2dvQHYwLjEwLjAtcmMuMS4wLjIwMjQwODE0MTAwMzAzLWRjM2JhMzAzMjJjYQpnbyBtb2QgdGlkeQ==" }
$ go get cuelang.org/go@v0.10.0-rc.1.0.20240814100303-dc3ba30322ca
...
$ go mod tidy
...
Expand Down
4 changes: 2 additions & 2 deletions hugo/content/en/docs/howto/write-a-type-switch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ output: [for v in input {
// Here, isANumber is implemented as a switch. Other, simpler,
// representations are also possible.
isANumber: [
if (v & number) != _|_ {true},
if (v & number) == _|_ {false},
if (v & number) != _|_ {true},
if (v & number) == _|_ {false},
][0]
}]
{{< /code-tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ definition.
name?: string
}
#Mammal: {
#Base// embedded
#Base // embedded
lungCapacityL: number
}
#Dog: {
#Mammal// embedded
#Mammal // embedded
kind!: "dog"
house: string
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ CUE has no switch or if-else construct, but these can be simulated using lists.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
mem: 2Gi
mem: 2Gi
footprint: [// select first
if mem < 1Gi {"small"},
if mem < 4Gi {"medium"},
"large",
if mem < 1Gi {"small"},
if mem < 4Gi {"medium"},
"large",
][0]
{{< /code-tab >}}
{{< code-tab name="CUE" language="cue" area="top-right" type="terminal" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ merging two maps.

{{< code-tabs >}}
{{< code-tab name="CUE" language="cue" area="top-left" >}}
let X = {list: []}
let X = {list: []}
a: X
b: X
c: X
Expand Down
47 changes: 47 additions & 0 deletions hugo/content/en/docs/reference/command/cue-help-embed/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
WARNING: "Code generated site_tool.cue; DO NOT EDIT."
title: "cue help embed"
aliases: ["/docs/reference/cli/cue-embed/"]
weight: 1000
tags:
- cue command
---

```text { title="TERMINAL" type="terminal" codeToCopy="Y3VlIGhlbHAgZW1iZWQ=" }
$ cue help embed
The @embed attribute can be used to load files as part of CUE evaluation.
Embedding must be enabled by a file-level @extern(embed) attribute.
Embed a single file as follows, which must exist when evaluating:
@extern(embed)
package foo
a: _ @embed(file=foo.json)
Embed many files of the same type with a glob pattern,
which inserts one field per file matched:
b: _ @embed(glob=images/*.*, type=binary)
b: [string]: bytes
Note that "**" glob patterns are not supported at this time.
If the file extension in "file" or "glob" does not imply a file type,
it must be specified with the "type" encoding as shown above.
See the "filetypes" help topic for more.
Files containing multiple documents cannot be embedded directly.
For NDJSON or multi-document YAML files, embed as type=text
and use APIs like yaml.Extract to decode as a list.
Note that embedding cue files is not supported at this time.
Note: support for embed is experimental, and is enabled via
CUE_EXPERIMENT=embed.
For more details and discussion, see the proposal linked from
https://cuelang.org/discussion/3264.
```
Loading

0 comments on commit e9f8c25

Please sign in to comment.