indexer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registered = map[string]Language{}

Registered indexers by language ID ("go", "objc", "cpp", etc.)

Functions

func Get

func Get(ctx context.Context, dataDir, indexDataDir, projectName string, autoCloneMissing bool) (map[string]schema.Index, error)

Get gets all the language indexes for the specified project.

When autoCloneMissing is true, if the project does not exist the server will attempt to `git clone <projectName> and index it. Beware, this may not be safe to enable if you have Git configured to access private repositories and the server is public!

func IndexDir

func IndexDir(ctx context.Context, dir string) (map[string]*schema.Index, error)

IndexDir indexes the specified directory recursively. It looks at the file extension of every file, and then asks the registered indexers for each language to index.

Returns the successful indexes and any errors.

func IndexForSearch

func IndexForSearch(projectName, indexDataDir string, indexes map[string]*schema.Index) error

IndexForSearch produces search indexes for the given project, writing them to:

index/<project_name>/search-index.sinter

func List

func List(indexDataDir string) ([]string, error)

Lists all indexes found in the index data directory.

func ReadAutoIndex

func ReadAutoIndex(path string) (map[string]AutoIndexedProject, error)

Read autoindexedProjects array from the provided filepath.

func Register

func Register(indexer Language)

Registers a doctree language indexer.

func RunIndexers

func RunIndexers(ctx context.Context, dir, dataDir, projectName string) error

Runs all the registered language indexes along with the search indexer and stores the results.

If an error is returned, it may be the case that some indexers succeeded while others failed.

func WriteAutoIndex

func WriteAutoIndex(path string, autoindexedProjects map[string]AutoIndexedProject) error

Write autoindexedProjects as JSON in the provided filepath.

func WriteIndexes

func WriteIndexes(projectName string, indexDataDir string, indexes map[string]*schema.Index) error

WriteIndexes writes indexes to the index data directory:

index/<project_name>/<language_id>

Types

type AutoIndexedProject

type AutoIndexedProject struct {
	// Name of the project to be auto-indexed
	Name string `json:"name"`
}

type Language

type Language interface {
	// Name of the language this indexer works for.
	Name() schema.Language

	// Extensions returns a list of file extensions commonly associated with the language.
	Extensions() []string

	// IndexDir indexes a directory of code likely to contain sources in this language recursively.
	IndexDir(ctx context.Context, dir string) (*schema.Index, error)
}

Language describes an indexer for a specific language.

type Result

type Result struct {
	Language    string  `json:"language"`
	ProjectName string  `json:"projectName"`
	SearchKey   string  `json:"searchKey"`
	Path        string  `json:"path"`
	ID          string  `json:"id"`
	Score       float64 `json:"score"`
}
func Search(ctx context.Context, indexDataDir, query, projectName string) ([]Result, error)

Directories

Path Synopsis
Package golang provides a doctree indexer implementation for Go.
Package golang provides a doctree indexer implementation for Go.
Package markdown provides a doctree indexer implementation for Markdown.
Package markdown provides a doctree indexer implementation for Markdown.
Package python provides a doctree indexer implementation for Python.
Package python provides a doctree indexer implementation for Python.
Package zig provides a doctree indexer implementation for Zig.
Package zig provides a doctree indexer implementation for Zig.

Jump to

Keyboard shortcuts

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