generator

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 17 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetaKeys = []MetaKey{
	"_isSubplotObj",
	"_isLinkedToArray",
	"_arrayAttrRegexps",
	"_deprecated",
	"description",
	"role",
	"editType",
	"impliedEdits",
}

Functions

func DownloadSchema added in v0.6.0

func DownloadSchema(version string, schemaURL string, outputpath string) (string, error)

DownloadSchema gets the schema file for a given version, and either saves the raw content, or prepares the file for the generator if prep is set to true

func UnmarshalRole

func UnmarshalRole(obj json.RawMessage, role *Role) error

Types

type AnimationAttributes added in v0.7.0

type AnimationAttributes struct {
	Names map[string]*Attribute `json:"-"`
}

func (*AnimationAttributes) UnmarshalJSON added in v0.7.0

func (attr *AnimationAttributes) UnmarshalJSON(b []byte) error

type Attribute

type Attribute struct {
	Role        Role   `json:"role,omitempty"`
	Description string `json:"description,omitempty"`
	EditType    string `json:"editType,omitempty"`

	ValType ValType       `json:"valType,omitempty"`
	Values  []interface{} `json:"values,omitempty"`
	Flags   []string      `json:"flags,omitempty"`
	Extras  []interface{} `json:"extras,omitempty"`
	Dflt    interface{}   `json:"dflt,omitempty"`
	Min     json.Number   `json:"min,omitempty"`
	Max     json.Number   `json:"max,omitempty"`
	ArrayOK bool          `json:"arrayOk,omitempty"`
	Anim    bool          `json:"anim,omitempty"`

	Name       string                `json:"-"`
	Attributes map[string]*Attribute `json:"-"`
	Items      map[string]*Attribute `json:"-"`
	Parent     *Attribute            `json:"-"`
}

func (*Attribute) String

func (attr *Attribute) String() string

type ConfigAttributes

type ConfigAttributes struct {
	Names map[string]*Attribute `json:"-"`
}

func (*ConfigAttributes) UnmarshalJSON

func (attr *ConfigAttributes) UnmarshalJSON(b []byte) error

type Creator

type Creator interface {
	Create(name string) (io.WriteCloser, error)
}

Creator provides the functionality to create a file

type Defs

type Defs struct {
	ValObjects map[string]*ValObject `json:"valObjects,omitempty"`
	MetaKeys   []string              `json:"meta_keys,omitempty"`
}

type Frames added in v0.7.0

type Frames struct {
	Attribute *Attribute `json:"-"`
}

func (*Frames) UnmarshalJSON added in v0.7.0

func (attr *Frames) UnmarshalJSON(b []byte) error

type Layout

type Layout struct {
	LayoutAttributes LayoutAttributes `json:"layoutAttributes,omitempty"`
}

type LayoutAttributes

type LayoutAttributes struct {
	Names map[string]*Attribute `json:"-"`
}

func (*LayoutAttributes) UnmarshalJSON

func (attr *LayoutAttributes) UnmarshalJSON(b []byte) error

type Meta

type Meta struct {
	Description string `json:"description,omitempty"`
}

type MetaKey

type MetaKey string

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer handles the process to render a Root to a Creator interface

func NewRenderer

func NewRenderer(fs Creator, root *Root) (*Renderer, error)

NewRenderer initializes a renderer

func (*Renderer) CreateAnimation added in v0.7.0

func (r *Renderer) CreateAnimation(dir string) error

CreateAnimation creates the config file in the given director

func (*Renderer) CreateConfig

func (r *Renderer) CreateConfig(dir string) error

CreateConfig creates the config file in the given director

func (*Renderer) CreateFrames added in v0.7.0

func (r *Renderer) CreateFrames(dir string) error

CreateFrames creates the config file in the given director

func (*Renderer) CreateLayout

func (r *Renderer) CreateLayout(dir string) error

CreateLayout creates the layout file in the given directory

func (*Renderer) CreatePlotly added in v0.5.0

func (r *Renderer) CreatePlotly(dir string, version Version) error

func (*Renderer) CreateTrace

func (r *Renderer) CreateTrace(dir string, name string) error

CreateTrace creates a file with the content of a trace by name

func (*Renderer) CreateTraces

func (r *Renderer) CreateTraces(dir string) error

CreateTraces creates all traces in the given directory

func (*Renderer) CreateUnmarshal

func (r *Renderer) CreateUnmarshal(dir string) error

CreateUnmarshal creates the unmarshal file on the given directory

func (*Renderer) CreateUnmarshalTests added in v0.6.0

func (r *Renderer) CreateUnmarshalTests(dir string) error

CreateUnmarshalTests creates the unmarshal file on the given directory

func (*Renderer) WriteAnimation added in v0.7.0

func (r *Renderer) WriteAnimation(w io.Writer) error

WriteAnimation writes config to the given writer

func (*Renderer) WriteConfig

func (r *Renderer) WriteConfig(w io.Writer) error

WriteConfig writes config to the given writer

func (*Renderer) WriteFrames added in v0.7.0

func (r *Renderer) WriteFrames(w io.Writer) error

WriteFrames writes config to the given writer

func (*Renderer) WriteLayout

func (r *Renderer) WriteLayout(w io.Writer) error

WriteLayout writes layout to the given writer

func (*Renderer) WritePlotGo added in v0.6.0

func (r *Renderer) WritePlotGo(w io.Writer, graphObjectsImportPath string, cdnUrl string) error

WritePlotly writes the base plotly file

func (*Renderer) WritePlotly added in v0.5.0

func (r *Renderer) WritePlotly(w io.Writer, version Version) error

WritePlotly writes the base plotly file

func (*Renderer) WriteTrace

func (r *Renderer) WriteTrace(traceName string, w io.Writer) error

WriteTrace writes a trace by name to a writer

func (*Renderer) WriteUnmarshal

func (r *Renderer) WriteUnmarshal(w io.Writer) error

WriteUnmarshal writes unmarshal to the given writer

func (*Renderer) WriteUnmarshalTests added in v0.6.0

func (r *Renderer) WriteUnmarshalTests(w io.Writer) error

WriteUnmarshal writes unmarshal to the given writer

type Role

type Role string
const (
	RoleObject Role = "object"
	RoleInfo   Role = "info"
	RoleStyle  Role = "style"
	RoleData   Role = "data"
)

type Root

type Root struct {
	SHA1     string  `json:"sha1,omitempty"`
	Modified bool    `json:"modified,omitempty"`
	Schema   *Schema `json:"schema,omitempty"`
}

Root represents the root of the plotly schema It is basically the struct representation of the json schema content

func LoadSchema

func LoadSchema(r io.Reader) (*Root, error)

LoadSchema loads the plotly schema file

type Schema

type Schema struct {
	Defs   *Defs  `json:"defs,omitempty"`
	Traces Traces `json:"traces,omitempty"`
	Layout Layout `json:"layout,omitempty"`
	// Transforms *Transforms `json:"transforms,omitempty"`
	Frames    *Frames              `json:"frames,omitempty"`
	Animation *AnimationAttributes `json:"animation,omitempty"`
	Config    *ConfigAttributes    `json:"config,omitempty"`
}

type Schemas added in v0.6.0

type Schemas struct {
	Versions []Version `yaml:"versions"`
}

type Trace

type Trace struct {
	Meta *Meta `json:"meta,omitempty"`
	// Categories []string   `json:"categories,omitempty"`
	Animatable       bool             `json:"animatable,omitempty"`
	Type             string           `json:"type,omitempty"`
	Attributes       TraceAttributes  `json:"attributes,omitempty"`
	LayoutAttributes LayoutAttributes `json:"layoutAttributes,omitempty"`
}

type TraceAttributes

type TraceAttributes struct {
	Type  string                `json:"type"`
	Names map[string]*Attribute `json:"-"`
}

func (*TraceAttributes) Sorted

func (attr *TraceAttributes) Sorted() []string

func (*TraceAttributes) UnmarshalJSON

func (attr *TraceAttributes) UnmarshalJSON(b []byte) error

type Traces

type Traces map[string]*Trace

type ValObject

type ValObject struct {
	Description  string   `json:"description,omitempty"`
	RequiredOpts []string `json:"requiredOpts,omitempty"`
	OtherOpts    []string `json:"otherOpts,omitempty"`
}

type ValType

type ValType string
const (
	ValTypeDataArray  ValType = "data_array"
	ValTypeEnum       ValType = "enumerated"
	ValTypeBoolean    ValType = "boolean"
	ValTypeNumber     ValType = "number"
	ValTypeInteger    ValType = "integer"
	ValTypeString     ValType = "string"
	ValTypeColor      ValType = "color"
	ValTypeColorlist  ValType = "colorlist"
	ValTypeColorscale ValType = "colorscale"
	ValTypeAngle      ValType = "angle"
	ValTypeSubplotID  ValType = "subplotid"
	ValTypeFlagList   ValType = "flaglist"
	ValTypeAny        ValType = "any"
	ValTypeInfoArray  ValType = "info_array"
)

type Version added in v0.6.0

type Version struct {
	Name      string `yaml:"Name"`      // name of the version
	Tag       string `yaml:"Tag"`       // git tag of the plotly version
	URL       string `yaml:"URL"`       // url under which the plotly schema json file can be downloaded directly
	Path      string `yaml:"Path"`      // path under which the schema file will be saved locally for future use
	Generated string `yaml:"Generated"` // path for the generated package
	Cdn       string `yaml:"CDN"`       // url for the cdn which should be included in the head of the generated html
}

func ReadSchemas added in v0.6.0

func ReadSchemas(schemapath string) []Version

Directories

Path Synopsis
cmd
downloader command
generator command
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL