feat: add enums to args (#45)

This commit is contained in:
Jeroen Op 't Eynde 2023-02-16 19:57:15 +01:00 committed by GitHub
parent 5e45c19fbe
commit cf4ff4b950
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 8 deletions

View file

@ -18,14 +18,14 @@ local d = import "github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet"
## Index
* [`fn arg(name, type, default)`](#fn-arg)
* [`fn arg(name, type, default, enums)`](#fn-arg)
* [`fn fn(help, args)`](#fn-fn)
* [`fn obj(help, fields)`](#fn-obj)
* [`fn pkg(name, url, help, filename='', version='master')`](#fn-pkg)
* [`fn render(obj)`](#fn-render)
* [`fn val(type, help, default)`](#fn-val)
* [`obj argument`](#obj-argument)
* [`fn new(name, type, default)`](#fn-argumentnew)
* [`fn new(name, type, default, enums)`](#fn-argumentnew)
* [`obj func`](#obj-func)
* [`fn new(help, args)`](#fn-funcnew)
* [`fn withArgs(args)`](#fn-funcwithargs)
@ -45,7 +45,7 @@ local d = import "github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet"
### fn arg
```ts
arg(name, type, default)
arg(name, type, default, enums)
```
`arg` is a shorthand for `argument.new`
@ -107,10 +107,22 @@ Utilities for creating function arguments
#### fn argument.new
```ts
new(name, type, default)
new(name, type, default, enums)
```
`new` creates a new function argument, taking the `name`, the `type`. Optionally it
can take a `default` value and `enum`-erate potential values.
Examples:
```jsonnet
[
d.argument.new('foo', d.T.string),
d.argument.new('bar', d.T.string, default='loo'),
d.argument.new('baz', d.T.number, enums=[1,2,3]),
]
```
new creates a new function argument, taking the name, the type and optionally a default value
### obj func