Skip to content

Commit f716cc3

Browse files
ctx variable was a bad idea
1 parent 148c4f0 commit f716cc3

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

graph_objects/attributes.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{- define "attributes" -}}
22
{{- $g := . -}}
3+
{{ $typeMap := dict "flaglist" "String" "info_array" "interface{}" "subplotid" "String" "data_array" "interface{}" "any" "interface{}" "angle" "float64" "color" "String" "number" "float64" "string" "String" "integer" "int64" "boolean" "Bool" }}
34
{{- $enumerates := dict }}
45
{{- $objects := dict }}
56
{{- $flaglists := dict }}
@@ -13,7 +14,7 @@
1314
{{/* Check if type map is defined and comment out if not*/}}
1415
{{- /*3*/ -}}{{- if eq $attr.valType "enumerated" }}{{ $_ := set $enumerates $typeName $attr }}
1516
{{- /*3*/ -}}{{- else if eq $attr.valType "flaglist" -}}{{ $_ := set $flaglists $typeName $attr }}
16-
{{- /*3*/ -}}{{- else if not (hasKey $g.ctx.typeMap $attr.valType) }}// Pending of type {{ quote $attr.valType -}}
17+
{{- /*3*/ -}}{{- else if not (hasKey $typeMap $attr.valType) }}// Pending of type {{ quote $attr.valType -}}
1718
{{- /*3*/ -}}{{- end -}}
1819
{{- $formatAttrName }} {{/*3*/}}{{ if eq $attr.valType "enumerated" -}}
1920
{{- $typeName }}
@@ -22,7 +23,7 @@
2223
{{- /*3*/}}{{- else if $attr.arrayOk -}}
2324
interface{}
2425
{{- else -}}
25-
{{ get $g.ctx.typeMap $attr.valType }}
26+
{{ get $typeMap $attr.valType }}
2627
{{- /*3*/ -}}{{- end }}
2728
{{- else if hasKey $attr "role" }}
2829
{{- if hasKey $attr "items" }}

graph_objects/config.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package grob
88

99

1010
type Config struct {
11-
{{- $params := (dict "parent" "Config" "attributes" .config "ctx" $g.ctx ) }}
11+
{{- $params := (dict "parent" "Config" "attributes" .config ) }}
1212
{{ template "attributes" $params }}
1313
}
1414
{{- $enumerates = merge $enumerates $params.enumerates }}

graph_objects/layout.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package grob
77

88

99
type Layout struct {
10-
{{- $params := (dict "parent" "Layout" "attributes" (merge .layout.layoutAttributes .extra ) "ctx" $g.ctx ) }}
10+
{{- $params := (dict "parent" "Layout" "attributes" (merge .layout.layoutAttributes .extra ) ) }}
1111
{{ template "attributes" $params }}
1212
{{- $enumerates = $params.enumerates -}}
1313
{{- $objects = $params.objects }}

graph_objects/main.tmpl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11

22

33
{{- $g := . -}}
4-
{{- $_ := set $g "ctx" dict -}}
5-
6-
{{ $_ := set $g.ctx "typeMap" (dict "flaglist" "String" "info_array" "interface{}" "subplotid" "String" "data_array" "interface{}" "any" "interface{}" "angle" "float64" "color" "String" "number" "float64" "string" "String" "integer" "int64" "boolean" "Bool") }}
74

85
Generating Go Plotly schema
96
SHA {{ .sha1 }}
@@ -13,7 +10,7 @@ SHA {{ .sha1 }}
1310
Something went wrong rendering plotly.go {{ $err }}
1411
{{ end }}
1512

16-
{{ $tracesInput := (dict "traces" $g.schema.traces "ctx" $g.ctx) }}
13+
{{ $tracesInput := (dict "traces" $g.schema.traces ) }}
1714
{{- $err := file "auto_traces.go" "traces" $tracesInput -}}
1815
{{ if $err }}
1916
Something went wrong rendering traces.go {{ $err }}
@@ -24,7 +21,7 @@ Objects in traces
2421
{{ $name }}
2522
{{- end }}
2623

27-
{{ $layoutInput := (dict "layout" $g.schema.layout "extra" $tracesInput.layoutAttributes "ctx" $g.ctx) }}
24+
{{ $layoutInput := (dict "layout" $g.schema.layout "extra" $tracesInput.layoutAttributes ) }}
2825
{{- $err := file "auto_layout.go" "layout" $layoutInput -}}
2926
{{ if $err }}
3027
Something went wrong rendering layout.go {{ $err }}
@@ -34,27 +31,27 @@ Objects in layout
3431
{{ $name }}
3532
{{- end }}
3633

37-
{{- $configInput := (dict "config" $g.schema.config "ctx" $g.ctx) }}
34+
{{- $configInput := (dict "config" $g.schema.config ) }}
3835
{{- $err := file "auto_config.go" "config" $configInput -}}
3936
{{ if $err }}
4037
Something went wrong rendering config.go {{ $err }}
4138
{{ end }}
4239

4340
Rendering objects.go
44-
{{ $objectsInput := (dict "objects" (merge $tracesInput.objects $layoutInput.objects $configInput.objects) "deep" 0 "ctx" $g.ctx) }}
41+
{{ $objectsInput := (dict "objects" (merge $tracesInput.objects $layoutInput.objects $configInput.objects) "deep" 0 ) }}
4542
{{- $err := file "auto_objects.go" "objects_recursive" $objectsInput -}}
4643
{{- if $err }}
4744
Something went wrong rendering objects.go {{ $err }}
4845
{{- end -}}
4946

5047
Rendering enumerates.go
51-
{{ $enumeratesInput := (dict "enumerates" (merge $tracesInput.enumerates $layoutInput.enumerates $objectsInput.enumerates $configInput.enumerates ) "ctx" $g.ctx) }}
48+
{{ $enumeratesInput := (dict "enumerates" (merge $tracesInput.enumerates $layoutInput.enumerates $objectsInput.enumerates $configInput.enumerates ) ) }}
5249
{{- $err := file "auto_enumerates.go" "enumerates" $enumeratesInput -}}
5350
{{- if $err }}
5451
Something went wrong rendering enumerates.go {{ $err }}
5552
{{- end }}
5653

57-
{{- $flaglistsInput := (dict "flaglists" (merge $tracesInput.flaglists $layoutInput.flaglists $objectsInput.flaglists $configInput.flaglists ) "ctx" $g.ctx) }}
54+
{{- $flaglistsInput := (dict "flaglists" (merge $tracesInput.flaglists $layoutInput.flaglists $objectsInput.flaglists $configInput.flaglists ) ) }}
5855
{{- $err := file "auto_flaglists.go" "flaglists" $flaglistsInput -}}
5956
{{- if $err }}
6057
Something went wrong rendering flaglist.go {{ $err }}

graph_objects/objects.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
type {{ $typeName }} interface{}
1919
{{/*1*/}}{{- else -}}
2020
type {{ $typeName }} struct {
21-
{{ $params := (dict "parent" $typeName "attributes" $obj "ctx" $g.ctx ) }}
21+
{{ $params := (dict "parent" $typeName "attributes" $obj ) }}
2222
{{- template "attributes" $params -}}
2323
{{- $enumerates = mustMerge $enumerates $params.enumerates }}
2424
{{- $innerObjects = mustMerge $innerObjects $params.objects -}}
@@ -44,7 +44,7 @@ package grob
4444
// DEEP {{ .deep -}}
4545

4646
{{- $fileName := print "objects_" .deep ".go" }}
47-
{{- $objectsInput := (dict "objects" .objects "ctx" $g.ctx) }}
47+
{{- $objectsInput := (dict "objects" .objects ) }}
4848
{{- template "objects" $objectsInput -}}
4949
{{- $enumerates = mustMerge $enumerates $objectsInput.enumerates }}
5050
{{- $flaglists = mustMerge $flaglists $objectsInput.flaglists }}
@@ -57,7 +57,7 @@ package grob
5757
{{- end }}
5858

5959
{{- if gt (len $objectsNested) 0 -}}
60-
{{ $nextInput := dict "objects" $objectsNested "deep" (add $g.deep 1) "ctx" $g.ctx }}
60+
{{ $nextInput := dict "objects" $objectsNested "deep" (add $g.deep 1) }}
6161
{{- template "objects_recursive" $nextInput -}}
6262
{{- $enumerates = merge $enumerates $nextInput.enumerates }}
6363
{{- $flaglists = merge $flaglists $nextInput.flaglists }}

graph_objects/traces.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type {{ $formatName }} struct {
1919

2020
// Type is the type of the plot
2121
Type TraceType `json:"type,omitempty"`
22-
{{- $params := (dict "parent" $formatName "attributes" .attributes "ctx" $g.ctx ) }}
22+
{{- $params := (dict "parent" $formatName "attributes" .attributes ) }}
2323
{{ template "attributes" $params }}
2424
{{- $enumerates = merge $enumerates $params.enumerates }}
2525
{{- $objects = merge $objects $params.objects }}

0 commit comments

Comments
 (0)