Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(external docs): Make better use of Cue definitions #4493

Merged
merged 14 commits into from Oct 10, 2020
30 changes: 16 additions & 14 deletions docs/reference.cue
Expand Up @@ -9,6 +9,8 @@ _values: {
current_timestamp: "2020-10-10T17:07:36.452332Z"
}

#Any: _ | {[_=string]: #Any}

#Classes: {
_args: kind: string
let args = _args
Expand Down Expand Up @@ -351,16 +353,16 @@ _values: {
relevant_when?: string
required: bool
type: {
"*": {}
"[string]"?: {
{"*": {}} |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will end up with a big oops unless closed. The evaluation will assume all types satisfy the values here, and rightfully so, since they can be expanded to satisfy the value, as they're not closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean exactly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works - nevermind :D

{"[string]": {
examples: [[string, ...string], ...[string, ...string]]
}
"string"?: {
}} |
{"string": {
examples: [string, ...string]
}
"timestamp"?: {
}} |
{"timestamp": {
examples: [_values.current_timestamp]
}
}}
}
}
}
Expand Down Expand Up @@ -392,7 +394,7 @@ _values: {
// `examples` clarify values through examples. This should be used
// when examples cannot be derived from the `default` or `enum`
// options.
examples: [...{[Name=string]: _}]
examples: [...#Any]

// `options` represent the child options for this option.
options: #Options | {}
Expand Down Expand Up @@ -486,22 +488,22 @@ _values: {
//
// For example, the `sinks.http.headers.*` option allows for arbitrary
// key/value pairs.
"*"?: {}
{"*": {}} |

// `[string]` represents an array of strings type.
"[string]"?: #OptionTypeArrayOfStrings & {_args: required: args.required}
{"[string]": #OptionTypeArrayOfStrings & {_args: required: args.required}} |

// `bool` represents a boolean tool.
"bool"?: #OptionTypeBool & {_args: required: args.required}
{"bool": #OptionTypeBool & {_args: required: args.required}} |

// `object` represents an object type that contains child options.
"object"?: #OptionTypeObject & {_args: required: args.required}
{"object": #OptionTypeObject & {_args: required: args.required}} |

// `strings` represents a string type.
"string"?: #OptionTypeString & {_args: required: args.required}
{"string": #OptionTypeString & {_args: required: args.required}} |

// `uint` represents a positive integer type.
"uint"?: #OptionTypeUint & {_args: required: args.required}
{"uint": #OptionTypeUint & {_args: required: args.required}}
}

#Statuses: {
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/components.cue
Expand Up @@ -116,6 +116,17 @@ components: {
}
}

_types: {
common: true
description: "Key/value pairs representing mapped log field names and types. This is used to coerce log fields into their proper types."
required: false
warnings: []
type: object: {
examples: [{"status": "int"}, {"duration": "float"}, {"success": "bool"}, {"timestamp": "timestamp|%F"}, {"timestamp": "timestamp|%a %b %e %T %Y"}, {"parent": {"child": "int"}}]
options: {}
}
}

{[Kind=string]: [Name=string]: {
kind: string

Expand Down
11 changes: 1 addition & 10 deletions docs/reference/components/transforms/regex_parser.cue
Expand Up @@ -84,16 +84,7 @@ components: transforms: regex_parser: {
examples: ["root_field", "parent.child"]
}
}
types: {
common: true
description: "Key/value pairs representing mapped log field names and types. This is used to coerce log fields into their proper types."
required: false
warnings: []
type: object: {
examples: [{"status": "int"}, {"duration": "float"}, {"success": "bool"}, {"timestamp": "timestamp|%F"}, {"timestamp": "timestamp|%a %b %e %T %Y"}, {"parent": {"child": "int"}}]
options: {}
}
}
types: components._types
}

examples: log: [
Expand Down