Documentation
¶
Index ¶
- func BuildIndex(path string, repos []Repo) error
- func BuildSearchIndex(cfg IndexConfig, githubToken string) error
- func EmbedFSServer(root embed.FS) http.Handler
- func FlagVar[T any, PT interface{ ... }](name string, value T, usage string) PT
- func NewSearchIndex(cfg IndexConfig) *searchIndex
- type Bounds
- type CodeSearchResult
- type Config
- type EnvString
- type ExitReason
- type Facet
- type FacetValue
- type File
- type FileResult
- type GitHubSourceConfig
- type IndexConfig
- type IndexInfo
- type LineResult
- type Query
- type Repo
- type RepoConfig
- type RepoFile
- type RepoSourceConfig
- type SearchIndex
- type SearchResult
- type SearchStats
- type ServeConfig
- type Tree
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildIndex ¶
BuildIndex creates a new index at `path` with the given `repos`.
func BuildSearchIndex ¶
func BuildSearchIndex(cfg IndexConfig, githubToken string) error
func EmbedFSServer ¶
EmbedFSServer creates an HTTP static file server on the OS.
The main distinction from http.FileServerFS is that it calculates and caches hashes for the underlying file system. An embed.FS is required since it can be assumed immutable and fixed, so hashes are cached indefinitely.
func NewSearchIndex ¶
func NewSearchIndex(cfg IndexConfig) *searchIndex
Types ¶
type CodeSearchResult ¶
type CodeSearchResult struct {
Stats SearchStats
Results []SearchResult
FileResults []FileResult
Facets []Facet
// unique index identity that served this request
IndexName string
IndexTime int
}
type Config ¶
type Config struct {
Index IndexConfig `json:"index"`
Serve ServeConfig `json:"serve"`
}
type EnvString ¶
type EnvString string
EnvString is a flag.Value that expands environment variables when fetched.
type ExitReason ¶
type ExitReason string
const ( ExitReasonNone ExitReason = "NONE" ExitReasonTimeout ExitReason = "TIMEOUT" ExitReasonMatchLimit ExitReason = "MATCH_LIMIT" )
func (ExitReason) String ¶
func (v ExitReason) String() string
type Facet ¶
type Facet struct {
Key string
Values []FacetValue
}
type FacetValue ¶
type FileResult ¶
type GitHubSourceConfig ¶
type GitHubSourceConfig struct {
// One and only one of org, user, or repo must be set.
Org string `json:"org"`
User string `json:"user"`
Repo string `json:"repo"`
Ref string `json:"ref"` // Defaults to HEAD.
Archived bool `json:"archived"`
Forks bool `json:"forks"` // Include archived or forked repos.
Reject string `json:"reject"` // Regexp, if not empty, to filter out repos from the index.
}
type IndexConfig ¶
type IndexConfig struct {
Name string `json:"name"` // The name of this grouping of repos. Defaults to path basename.
Path string `json:"path"` // A directory holding all of the indexes and git data.
Repos []RepoConfig `json:"repos"` // Repositories to fetch.
RepoSources RepoSourceConfig `json:"reposources"` // Sources that expand into more repos.
}
type LineResult ¶
type Query ¶
type Query struct {
Line string // Freeform regexp
// File & Repo inclusion/exclusion regexps:
File, NotFile []string
Repo, NotRepo, Tags, NotTags string
RepoFilter []string // Additional exact-match repository filter
FoldCase bool // Ignore case when searching.
MaxMatches int // Max matches to return. Must be set.
FilenameOnly bool // Search for `Line` only in file names.
ContextLines int // Results have the N lines before and after matched line.
}
type Repo ¶
type Repo interface {
// Name is the unique ref name this Repo tracks in the underlying repository.
Name() string
// For git, Version yields the SHA1 of the commit.
Version() Version
// Files yields all of the files in the tree at the current Version.
// For git, Refresh may be called concurrently, unless it deletes underlying objects.
Files(yield func(RepoFile) error) error
// Refresh fetches the remote and updates the local tracking ref.
Refresh() (Version, error)
}
type RepoConfig ¶
type RepoConfig struct {
Name string // Optional, defaults to base path of URL. Must be unique.
RemoteURL string // Remote URL.
RemoteRef string // Remote reference / branch / etc.
}
func ResolveFetchSpecs ¶
func ResolveFetchSpecs(client *github.Client, specs []GitHubSourceConfig, auth *url.Userinfo) ([]RepoConfig, error)
type RepoSourceConfig ¶
type RepoSourceConfig struct {
GitHub []GitHubSourceConfig `json:"github"`
}
type SearchIndex ¶
type SearchIndex interface {
// User visible name of the index
Name() string
// Info returns the metadata about the index.
// Background data updates may cause this info to update.
Info() IndexInfo
// Paths returns the list of file paths in this index.
Paths(tree, version, pathPrefix string) []File
// Data returns the full data for the file at the path.
// If the path is not found in this index, data returned will be empty.
Data(tree, version, path string) string
// Search returns search results.
// Errors will be returned if the query is invalid.
// The context may be used to cancel the search.
Search(ctx context.Context, q Query) (*CodeSearchResult, error)
// Reload will refresh the index if it has been changed on disk.
Reload()
}
type SearchResult ¶
type SearchResult struct {
File File
Lines []LineResult
}
type SearchStats ¶
type SearchStats struct {
TotalTime int64
ExitReason ExitReason
}
type ServeConfig ¶
type ServeConfig struct {
DefaultMaxMatches int `json:"default_max_matches"`
Templates struct {
// TODO: move page customizations into a sub struct.
Feedback struct {
MailTo string `json:"mailto"` // The mailto address for the "feedback" url.
} `json:"feedback"`
HeaderHTML template.HTML `json:"header_html"` // HTML injected into layout template for site-specific customizations.
FooterHTML template.HTML `json:"footer_html"` // HTML injected into layout template just before </body> for site-specific customization.
} `json:"templates"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
csbuild
command
|
|
|
csweb
command
|
|
|
codesearch
|
|
|
regexp
Package regexp implements regular expression search tuned for use in grep-like programs.
|
Package regexp implements regular expression search tuned for use in grep-like programs. |
|
sparse
Package sparse implements sparse sets.
|
Package sparse implements sparse sets. |
|
livegrep
|
|
|
server/build
command
|
|
|
server/gencss
command
|
|
|
server/views
templ: version: v0.3.960
|
templ: version: v0.3.960 |
Click to show internal directories.
Click to hide internal directories.