parser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoSpec = &LanguageSpec{
	NamedChunks: map[string]NamedChunkExtractor{
		"function_declaration": {
			NameQuery: `(function_declaration name: (identifier) @name)`,
		},
		"method_declaration": {
			NameQuery: `(method_declaration name: (field_identifier) @name)`,
			ParentNameQuery: `
				(method_declaration
					receiver: (parameter_list
						(parameter_declaration
							type: [
								(type_identifier) @name
								(pointer_type
									(type_identifier) @name)
								(generic_type
									(type_identifier) @name)
								(pointer_type
									(generic_type
										(type_identifier) @name))])))`,
		},
		"type_declaration": {
			NameQuery: `
				(type_declaration [
					(type_spec name: (type_identifier) @name)
					(type_alias name: (type_identifier) @name)])`,
		},
		"var_declaration": {
			NameQuery: `(var_declaration (var_spec name: (identifier) @name))`,
		},
		"const_declaration": {
			NameQuery: `(const_declaration (const_spec name: (identifier) @name))`,
		},
	},
	Ignore: []string{
		"package_clause",
	},
	FileTypeRules: []FileTypeRule{
		{Pattern: "**/*_test.go", Type: FileTypeTests},
		{Pattern: "vendor/**", Type: FileTypeIgnore},
		{Pattern: "third_party/**", Type: FileTypeIgnore},
	},
}
View Source
var MarkdownSpec = &LanguageSpec{
	ExtractChildrenIn: []string{"section"},
	Ignore: []string{

		"atx_heading", "setext_heading",

		"block_quote",
		"block_continuation",
		"fenced_code_block", "indented_code_block",
		"html_block",
		"link_reference_definition",
		"list",
		"paragraph",
		"pipe_table",
		"thematic_break",
	},
	FileTypeRules: []FileTypeRule{
		{Pattern: "**/*.md", Type: FileTypeDocs},
	},
}

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	File        string // file path within workspace
	Type        string
	Path        string // path within file
	Summary     string
	Source      string
	StartLine   uint
	StartColumn uint
	EndLine     uint
	EndColumn   uint
	ParsedAt    int64
}

func (*Chunk) ID

func (c *Chunk) ID() string

type File

type File struct {
	Path   string // path within workspace
	Chunks []*Chunk
	Source []byte
	// contains filtered or unexported fields
}

type FileType added in v0.3.0

type FileType string
const (
	FileTypeSrc    FileType = "src"
	FileTypeTests  FileType = "tests"
	FileTypeDocs   FileType = "docs"
	FileTypeIgnore FileType = "ignore"
)

type FileTypeRule added in v0.3.0

type FileTypeRule struct {
	Pattern string
	Type    FileType
}

type LanguageSpec

type LanguageSpec struct {
	NamedChunks       map[string]NamedChunkExtractor
	ExtractChildrenIn []string
	Ignore            []string
	FileTypeRules     []FileTypeRule
}

type NamedChunkExtractor

type NamedChunkExtractor struct {
	NameQuery       string
	ParentNameQuery string
}

type Parser

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

func NewGoParser

func NewGoParser(workspaceRoot string) (*Parser, error)

func NewMarkdownParser added in v0.3.0

func NewMarkdownParser(workspaceRoot string) (*Parser, error)

func (*Parser) Chunk

func (p *Parser) Chunk(filePath string) (*File, error)

func (*Parser) Close

func (p *Parser) Close()

Jump to

Keyboard shortcuts

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