Skip to content

Commit

Permalink
fix: Cleanup codegen and formatting. (#835)
Browse files Browse the repository at this point in the history
This change fixes issues with code generation and go code formatting.
  • Loading branch information
betterengineering authored Jul 31, 2023
1 parent 52a7f61 commit 230ff2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ render.Column(


## Image
Image renders the image data passed via `src`. `src` accepts a string and supports file URLs, SVG as a string, as well as image binary data. Supported binary data formats include PNG, JPEG and GIF.
Image renders the binary image data passed via `src`. Supported
formats include PNG, JPEG, GIF, and SVG.

If `width` or `height` are set, the image will be scaled
accordingly, with nearest neighbor interpolation. Otherwise the
Expand All @@ -173,7 +174,7 @@ the `delay` attribute.
#### Attributes
| Name | Type | Description | Required |
| --- | --- | --- | --- |
| `src` | `str` | Binary image data or svg text | **Y** |
| `src` | `str` | Binary image data or SVG text | **Y** |
| `width` | `int` | Scale image to this width | N |
| `height` | `int` | Scale image to this height | N |
| `delay` | `int` | (Read-only) Frame delay in ms, for animated GIFs | N |
Expand Down
4 changes: 2 additions & 2 deletions render/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// Image renders the binary image data passed via `src`. Supported
// formats include PNG, JPEG and GIF.
// formats include PNG, JPEG, GIF, and SVG.
//
// If `width` or `height` are set, the image will be scaled
// accordingly, with nearest neighbor interpolation. Otherwise the
Expand All @@ -31,7 +31,7 @@ import (
// also be animated. Frame delay (in milliseconds) can be read from
// the `delay` attribute.
//
// DOC(Src): Binary image data
// DOC(Src): Binary image data or SVG text
// DOC(Width): Scale image to this width
// DOC(Height): Scale image to this height
// DOC(Delay): (Read-only) Frame delay in ms, for animated GIFs
Expand Down
7 changes: 4 additions & 3 deletions runtime/gen/header/render.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ var renderModule = RenderModule{}

func LoadRenderModule() (starlark.StringDict, error) {
renderModule.once.Do(func() {
fnt := starlark.NewDict(len(render.Font))
for k, _ := range render.Font {
fnt.SetKey(starlark.String(k), starlark.String(k))
fontList := render.GetFontList()
fnt := starlark.NewDict(len(fontList))
for _, name := range fontList {
fnt.SetKey(starlark.String(name), starlark.String(name))
}
fnt.Freeze()

Expand Down
6 changes: 3 additions & 3 deletions runtime/modules/hmac/hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func LoadModule() (starlark.StringDict, error) {
func fnHmac(hashFunc func() hash.Hash) func(*starlark.Thread, *starlark.Builtin, starlark.Tuple, []starlark.Tuple) (starlark.Value, error) {
return func(t *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
key starlark.Value
s starlark.String
key starlark.Value
s starlark.String
binary bool = false
)
if err := starlark.UnpackArgs(fn.Name(), args, kwargs, "key", &key, "s", &s, "binary?", &binary); err != nil {
Expand Down Expand Up @@ -77,4 +77,4 @@ func fnHmac(hashFunc func() hash.Hash) func(*starlark.Thread, *starlark.Builtin,
}
return starlark.String(fmt.Sprintf("%x", digest)), nil
}
}
}

0 comments on commit 230ff2b

Please sign in to comment.