spec

package
v0.0.0-...-1eec07d Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const RoutePrefixKey = "prefix"

Define the constants used in the spec

Variables

This section is empty.

Functions

func PrintSpec

func PrintSpec(siteSpec SiteSpec)

func SetServiceName

func SetServiceName(spec *SiteSpec) (string, error)

Types

type Annotation

type Annotation struct {
	Properties map[string]interface{}
}

Annotation defines key-value properties for annotations

func NewAnnotation

func NewAnnotation(properties map[string]interface{}) Annotation

NewAnnotation creates a new annotation

type ArrayType

type ArrayType struct {
	Name  string
	Value Type
}

ArrayType describes an array type

func NewArrayType

func NewArrayType(value Type) *ArrayType

NewArrayType creates a new array type

func (*ArrayType) GetComments

func (t *ArrayType) GetComments() []string

func (*ArrayType) GetDocuments

func (t *ArrayType) GetDocuments() []string

func (*ArrayType) GetFields

func (t *ArrayType) GetFields() []Field

func (*ArrayType) GetName

func (t *ArrayType) GetName() string

Methods to implement the Type interface for ArrayType

type Doc

type Doc []string

Doc represents documentation strings

type DocNode

type DocNode struct {
	Annotation Annotation
}

DocNode represents a doc block in a handler

func NewDocNode

func NewDocNode(annotation Annotation) *DocNode

NewDocNode creates a new doc node

type Field

type Field struct {
	Name    string
	Type    string
	Tag     string
	Comment string
	Docs    Doc
}

Field describes the field of a structure

func (*Field) GetComments

func (t *Field) GetComments() []string

func (*Field) GetDocuments

func (t *Field) GetDocuments() []string

func (*Field) GetFields

func (t *Field) GetFields() []Field

func (*Field) GetName

func (t *Field) GetName() string

Methods to implement the Type interface for Field

type Handler

type Handler struct {
	Name    string
	Methods []Method
}

Handler describes a Site handler

func NewHandler

func NewHandler(name string, methods []Method) *Handler

NewHandler creates a new handler node

type InterfaceType

type InterfaceType struct {
	Name string
}

InterfaceType describes an interface type

func NewInterfaceType

func NewInterfaceType(name string) *InterfaceType

NewInterfaceType creates a new interface type

func (*InterfaceType) GetComments

func (t *InterfaceType) GetComments() []string

func (*InterfaceType) GetDocuments

func (t *InterfaceType) GetDocuments() []string

func (*InterfaceType) GetFields

func (t *InterfaceType) GetFields() []Field

func (*InterfaceType) GetName

func (t *InterfaceType) GetName() string

Methods to implement the Type interface for InterfaceType

type MapType

type MapType struct {
	Name  string
	Key   string
	Value Type
}

MapType describes a map type

func NewMapType

func NewMapType(key string, value Type) *MapType

NewMapType creates a new map type

func (*MapType) GetComments

func (t *MapType) GetComments() []string

func (*MapType) GetDocuments

func (t *MapType) GetDocuments() []string

func (*MapType) GetFields

func (t *MapType) GetFields() []Field

func (*MapType) GetName

func (t *MapType) GetName() string

Methods to implement the Type interface for MapType

type MenuEntry struct {
	Title       string
	Weight      int
	Icon        string
	URL         string
	Subtitle    string
	MobileTitle string
	Lead        string
	InMobile    bool
	IsAtEnd     bool
	IsDropdown  bool
	HxDisable   bool
	Parent      string
	Children    []MenuEntry
	Attributes  map[string]string
	IsButton    bool
}

Define the types used in the spec

func NewMenuEntries

func NewMenuEntries(entries []ast.MenuEntry) []MenuEntry

func NewMenuEntry

func NewMenuEntry(entry ast.MenuEntry) MenuEntry

type Method

type Method struct {
	Method             string
	Prefix             string
	Route              string
	StaticRouteRewrite string
	Request            string
	RequestType        Type
	Response           string
	ResponseType       Type
	Page               *Page
	Doc                *DocNode
	HandlerDoc         Doc
	HandlerComment     Doc
	DocAnnotation      Annotation
	SocketNode         *SocketNode
	PubSubNode         *PubSubNode
	HasRequestType     bool
	HasResponseType    bool
	HasPage            bool
	ReturnsPartial     bool
	ReturnsPlainText   bool
	ReturnsJson        bool
	ReturnsRedirect    bool
	RedirectURL        string
	IsStatic           bool
	IsStaticEmbed      bool
	IsSocket           bool
	IsDownload         bool
	IsPubSub           bool
	IsSSE              bool
	IsVideoStream      bool
	IsAudioStream      bool
	IsFullHTMLPage     bool
	NoOutput           bool
}

Define the types used in the spec

func NewMethod

func NewMethod(m ast.MethodNode,
	page *Page,
	doc *DocNode,
	socketNode *SocketNode,
	pubSubNode *PubSubNode) Method

NewMethod creates a new method for a handler. m, buildPage(m.Page), buildDoc(m.Doc), buildSocketNode(m.SocketNode)

func (*Method) GetComments

func (m *Method) GetComments() []string

func (*Method) GetDocuments

func (m *Method) GetDocuments() []string

func (*Method) GetFields

func (m *Method) GetFields() []Field

func (*Method) GetName

func (m *Method) GetName() string

Methods to implement the Type interface for Method

type Module

type Module struct {
	Name   string
	Source string
	Prefix string
	Attr   map[string]interface{}
}

Module describes an external module

func NewModule

func NewModule(name string, attr map[string]interface{}) Module

NewModule creates a new module node

type Page

type Page struct {
	Annotation Annotation
}

Page represents a page in a handler

func NewPage

func NewPage(annotation Annotation) *Page

NewPage creates a new page node

type PointerType

type PointerType struct {
	Name string
	Type Type
}

PointerType describes a pointer type

func NewPointerType

func NewPointerType(t Type) *PointerType

NewPointerType creates a new pointer type

func (*PointerType) GetComments

func (t *PointerType) GetComments() []string

func (*PointerType) GetDocuments

func (t *PointerType) GetDocuments() []string

func (*PointerType) GetFields

func (t *PointerType) GetFields() []Field

func (*PointerType) GetName

func (t *PointerType) GetName() string

Methods to implement the Type interface for PointerType

type PrimitiveType

type PrimitiveType struct {
	Name string
}

PrimitiveType describes a primitive type

func NewPrimitiveType

func NewPrimitiveType(name string) *PrimitiveType

NewPrimitiveType creates a new primitive type

func (*PrimitiveType) GetComments

func (t *PrimitiveType) GetComments() []string

func (*PrimitiveType) GetDocuments

func (t *PrimitiveType) GetDocuments() []string

func (*PrimitiveType) GetFields

func (t *PrimitiveType) GetFields() []Field

func (*PrimitiveType) GetName

func (t *PrimitiveType) GetName() string

Methods to implement the Type interface for PrimitiveType

type PubSubNode

type PubSubNode struct {
	Method string
	Route  string
	Topic  TopicNode
}

Define the types used in the spec

func NewPubSubNode

func NewPubSubNode(method, route string, topicNode ast.TopicNode) *PubSubNode

type RequestType

type RequestType int
const (
	FullHTMLPage RequestType = iota
	PartialHTML
	JSONOutput
	NoOutput
	FormSubmission // Includes both regular form data and file uploads
	WebSocket
	SSEStream
	VideoStream
	AudioStream
)

func DetermineRequestType

func DetermineRequestType(method *ast.MethodNode) RequestType

type Server

type Server struct {
	Annotation Annotation
	Services   []Service
}

Server describes a server block with its services

func NewServer

func NewServer(annotation Annotation) *Server

NewServer creates a new server node

func (Server) GetAnnotation

func (s Server) GetAnnotation(key string) string

annotation methods GetAnnotation returns the value by specified key from @server

type Service

type Service struct {
	Name     string
	Handlers []Handler
}

Service describes a Site service with its handlers

func NewService

func NewService(name string) *Service

NewService creates a new service node

type SiteSpec

type SiteSpec struct {
	Name    string
	Types   []Type
	Servers []Server
	Modules []Module
	Menus   map[string][]MenuEntry
}

SiteSpec describes a Site file

func BuildSiteSpec

func BuildSiteSpec(ast ast.SiteAST) *SiteSpec

func (*SiteSpec) Validate

func (spec *SiteSpec) Validate() error

Validate checks the integrity of the SiteSpec

type SocketNode

type SocketNode struct {
	Method string
	Route  string
	Topics []TopicNode
}

Define the types used in the spec

func NewSocketNode

func NewSocketNode(method, route string, topicNodes []ast.TopicNode) *SocketNode

type StructType

type StructType struct {
	Name    string
	Fields  []Field
	Docs    Doc
	Comment Doc
}

StructType describes a structure type

func NewStructType

func NewStructType(name string, fields []Field, docs, comment Doc) *StructType

NewStructType creates a new struct type

func (*StructType) GetComments

func (t *StructType) GetComments() []string

func (*StructType) GetDocuments

func (t *StructType) GetDocuments() []string

func (*StructType) GetFields

func (t *StructType) GetFields() []Field

func (*StructType) GetName

func (t *StructType) GetName() string

Methods to implement the Type interface for StructType

type TopicNode

type TopicNode struct {
	Topic             string
	ResponseTopic     string
	InitiatedByClient bool
	RequestType       Type
	ResponseType      Type
}

Define the types used in the spec

func NewTopicNode

func NewTopicNode(topic, responseTopic string, initiatedByClient bool, requestType, responseType interface{}) TopicNode

func (*TopicNode) GetComments

func (m *TopicNode) GetComments() []string

func (*TopicNode) GetDocuments

func (m *TopicNode) GetDocuments() []string

func (*TopicNode) GetFields

func (m *TopicNode) GetFields() []Field

func (*TopicNode) GetName

func (m *TopicNode) GetName() string

Methods to implement the Type interface for TopicNode

type Type

type Type interface {
	GetName() string
	GetFields() []Field
	GetComments() []string
	GetDocuments() []string
}

Type defines the types used in the Site spec

Jump to

Keyboard shortcuts

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