cmds

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cmds is sort of like ast for oapenapi commands. Its sole purpose is to given package and command recognize what it is and what arguments are available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCommentGroup

func ParseCommentGroup(gg *ast.CommentGroup) []string

ParseCommentGroup will take ast comment group and returns parsed comments as a strings.

Types

type Args

type Args []string

Args are aguements to commands

func (Args) Get

func (a Args) Get(index uint) (string, bool)

Get will return value and true if at given index argument exists.

func (Args) Len

func (a Args) Len() int

Len return length of arguments

type CmdBase

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

CmdBase is base command

func (CmdBase) GetArgs

func (c CmdBase) GetArgs() Args

GetArgs returns arguments of command

func (CmdBase) GetCmd

func (c CmdBase) GetCmd() CmdKind

GetCmd returns matched command.

type CmdKind

type CmdKind string

CmdKind is command kind

const (
	// RootKind is root command
	RootKind CmdKind = ":root"
	// SchemaKind is schema command
	SchemaKind CmdKind = ":schema"
)

type CmdRoot

type CmdRoot struct {
	CmdBase
}

CmdRoot root command parses the syntax '//openapi ....'. Dummy schema for now.

func NewCmdRoot

func NewCmdRoot(cmd CmdBase) (CmdRoot, error)

NewCmdRoot creates new root schema

type CmdSchema

type CmdSchema struct {
	CmdBase
	Name string
	Ptr  pointer.Pointer
}

CmdSchema is command responsible for allowing schema exports to be possible. It has simple syntax: //oapi:schema <uri>, causing schema to be exported at root of document usually components.*.

type Commander

type Commander interface {
	GetCmd() CmdKind
	GetArgs() Args
}

Commander interface allows to unite and cast given comments at need.

func NewCmdSchema

func NewCmdSchema(cmd CmdBase) (s Commander, err error)

NewCmdSchema creates new command schema

func Parse

func Parse(pkg *packages.Package, comment string) (s Commander, err error)

Parse will parse pacage with given comment, returning command.

type List

type List []Commander

List is list of commands

func (List) Pointers

func (cc List) Pointers() pointer.Pointers

Pointers will list of pointers

type Map

type Map map[string]List

Map is a map of commands

func (Map) Pointers

func (cc Map) Pointers() (pp pointer.Pointers)

Pointers retuns list of pointers

type Scanner

type Scanner struct {
	Commands Map
}

Scanner allow to scan go code for commands. Commands are specific comments allowing to alter behaviour of scanner.

func NewScanner

func NewScanner() *Scanner

NewScanner creates new scanner.

func (*Scanner) ExportedComponents

func (r *Scanner) ExportedComponents() (exports resolver.Exports, err error)

ExportedComponents will provide exported components in a form of resolver.Exports.

func (*Scanner) Scan

func (r *Scanner) Scan(pkg *packages.Package) (err error)

Scan will scan package and store info.

Jump to

Keyboard shortcuts

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