66 lines
1.9 KiB
Go
66 lines
1.9 KiB
Go
// Package parser contains the code parser for the WebAwesome library.
|
|
package parser
|
|
|
|
// WebTypes represents the root structure of web-types.json
|
|
type WebTypes struct {
|
|
Schema string `json:"$schema"`
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
DescriptionMarkup string `json:"description-markup"`
|
|
Contributions struct {
|
|
HTML struct {
|
|
Elements []Element `json:"elements"`
|
|
} `json:"html"`
|
|
} `json:"contributions"`
|
|
}
|
|
|
|
// Element represents a web component definition
|
|
type Element struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
DocURL string `json:"doc-url"`
|
|
Attributes []Attribute `json:"attributes"`
|
|
Slots []Slot `json:"slots"`
|
|
Events []Event `json:"events"`
|
|
JS JSInfo `json:"js"`
|
|
}
|
|
|
|
// Attribute represents a component attribute/property
|
|
type Attribute struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Value AttributeValue `json:"value"`
|
|
}
|
|
|
|
// AttributeValue contains type and default value info
|
|
type AttributeValue struct {
|
|
Type string `json:"type"`
|
|
Default string `json:"default,omitempty"`
|
|
}
|
|
|
|
// Slot represents a named slot in the component
|
|
type Slot struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// Event represents an event emitted by the component
|
|
type Event struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type,omitempty"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// JSInfo contains JavaScript-specific property and event info
|
|
type JSInfo struct {
|
|
Properties []JSProperty `json:"properties"`
|
|
Events []Event `json:"events"`
|
|
}
|
|
|
|
// JSProperty represents a JavaScript property
|
|
type JSProperty struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|