easyparser

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 13 Imported by: 7

README

go-easyparser

Parse Go packages with ease

Documentation

Overview

Package easyparser provides a Go module parser for AST

Package easyparser provides a Go module parser for AST

Package easyparser provides a Go module parser for AST

Package easyparser provides a Go module parser for AST

Package easyparser provides a Go module parser for AST

Package easyparser provides a Go module parser for AST

Index

Constants

This section is empty.

Variables

View Source
var All = func(opt *FilterOpt) bool {
	return true
}

All exports all interfaces

View Source
var Default = func(opt *FilterOpt) bool {
	if !opt.BasePackage {
		return false
	}

	if !opt.Exported {
		return false
	}

	return true
}

Default exports all other than neither in base-package nor exported

Functions

func GetPackageNameFromPath added in v0.3.3

func GetPackageNameFromPath(s string) string

GetPackageNameFromPath - get package name from last element of path

func SplitPackageStruct added in v0.3.3

func SplitPackageStruct(s string) (string, string)

SplitPackageStruct - split package.struct

Types

type FilterOpt

type FilterOpt struct {
	BasePackage bool
	Package     string
	Name        string
	Exported    bool
	// Dependency - 他のstructから依存されている場合にtrueとなる
	// 同じstructに対して複数回呼ばれ、依存されていない状況ではfalseとして呼ばれる可能性がある
	// 一度でもtrueとして返せば出力される
	// dependencyがfalseの時にtrueを返す場合、trueでも常にtrueを返すべきである
	Dependency bool
}

FilterOpt is options to filter exported interfaces

type Parser

type Parser struct {
	Filter   func(opt *FilterOpt) bool
	Replacer func(t types.Type) tstypes.Type
	// ForceMapNonNullable provides backward compatibility to interpret map as non-nullable
	ForceMapNonNullable bool
	// contains filtered or unexported fields
}

Parser is a Go module parser for TypeScript AST

func NewParser

func NewParser(dir string, filter func(*FilterOpt) bool) (*Parser, error)

NewParser initializes a new Parser

func (*Parser) GetBasePackage

func (p *Parser) GetBasePackage() string

GetBasePackage returns a base module for the root package

func (*Parser) Parse

func (p *Parser) Parse() (res map[string]tstypes.Type, err error)

Parse parses the Go module and returns ASTs

Directories

Path Synopsis
Package testutil offers test utility for parser
Package testutil offers test utility for parser
Package types contains structs/interfaces representing TypeScript types
Package types contains structs/interfaces representing TypeScript types

Jump to

Keyboard shortcuts

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