parser

package
v2.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIgnoredFolders = []string{"vendor", ".git", "node_modules", ".idea", "_fixtures"}

Functions

func IsProspect

func IsProspect(path string, ignore ...string) bool

Types

type Box

type Box struct {
	Name       string // name of the box
	Path       string // relative path of folder NewBox("./templates")
	AbsPath    string // absolute path of Path
	Package    string // the package name the box was found in
	PWD        string // the PWD when the parser was run
	PackageDir string // the absolute path of the package where the box was found
}

Box found while parsing a file

func NewBox

func NewBox(name string, path string) *Box

NewBox stub from the name and the path provided

func (Box) String

func (b Box) String() string

String - json returned

type File

type File struct {
	io.Reader
	Path    string
	AbsPath string
}

File that is to be parsed

func NewFile

func NewFile(path string, r io.Reader) *File

NewFile takes the name of the file you want to write to and a reader to reader from

func (File) Name

func (f File) Name() string

Name of the file "app.go"

func (*File) String

func (f *File) String() string

String returns the contents of the reader

func (*File) Write

func (s *File) Write(p []byte) (int, error)

type Parser

type Parser struct {
	Prospects     []*File // a list of files to check for boxes
	IgnoreImports bool
}

Parser to find boxes

func New

func New(prospects ...*File) *Parser

New Parser from a list of File

func NewFromRoots

func NewFromRoots(roots []string, opts *RootsOptions) (*Parser, error)

NewFromRoots scans the file roots provided and returns a new Parser containing the prospects

func (*Parser) Run

func (p *Parser) Run() ([]*Box, error)

Run the parser and run any boxes found

type RootsOptions

type RootsOptions struct {
	IgnoreImports bool
	Ignores       []string
}

func (RootsOptions) String

func (r RootsOptions) String() string

type Visitor

type Visitor struct {
	File    genny.File
	Package string
	// contains filtered or unexported fields
}

func NewVisitor

func NewVisitor(f *File) *Visitor

func (*Visitor) Run

func (v *Visitor) Run() ([]*Box, error)

func (*Visitor) Visit

func (v *Visitor) Visit(node ast.Node) ast.Visitor

Directories

Path Synopsis
_fixtures

Jump to

Keyboard shortcuts

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