source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	Slug        string
	Name        string
	Kind        string // "class", "interface", "trait", "module"
	Description string
	SourceFile  string
	SourceCode  string
	URL         string
	Properties  []Property
}

Entity represents a top-level documentation entity (class, module, etc.)

type FetchFunc

type FetchFunc func(ctx context.Context, url string) ([]byte, error)

FetchFunc is a rate-limited HTTP fetch function provided by the crawler.

type LibraryMeta

type LibraryMeta struct {
	Name        string
	Description string
	SourceURL   string
	Version     string
	TrustScore  float64
}

LibraryMeta holds metadata for library registration.

type Method

type Method struct {
	Slug          string
	Name          string
	Signature     string
	Description   string
	Parameters    []Parameter
	ReturnType    string
	ReturnDesc    string
	SourceCode    string
	WrappedSource string
	WrappedMethod string
	URL           string
	Since         string
	Relations     []Relation
}

Method represents a method/function with full details.

type Parameter

type Parameter struct {
	Name        string
	Type        string
	Required    bool
	Description string
}

Parameter describes a function/method parameter.

type Property

type Property struct {
	Name        string
	Type        string
	Description string
	Visibility  string
	Since       string
}

Property represents a class/entity property.

type Relation

type Relation struct {
	Kind        string // "uses", "used_by"
	TargetName  string // "WP_Query::get_posts()"
	TargetURL   string
	Description string
}

Relation is a cross-reference to another method/function.

type Source

type Source interface {
	// ID returns the canonical library ID (e.g., "/wordpress/classes").
	ID() string

	// Meta returns metadata for the library record.
	Meta() LibraryMeta

	// DiscoverEntities returns URLs of all top-level entities to crawl.
	DiscoverEntities(ctx context.Context, fetch FetchFunc) ([]string, error)

	// ParseEntity parses a single entity page and returns its data
	// plus a list of method URLs to crawl next.
	ParseEntity(ctx context.Context, url string, body []byte) (*Entity, []string, error)

	// ParseMethod parses a single method/function detail page.
	ParseMethod(ctx context.Context, url string, body []byte) (*Method, error)

	// DetectWrapper analyzes a method's source code and returns wrapper info.
	// Returns (isWrapper, targetName, targetKind) where targetKind is
	// "function", "self_method", or "static_method".
	DetectWrapper(method *Method) (bool, string, string)

	// ResolveWrapperURL constructs the URL to fetch the wrapped method's page.
	ResolveWrapperURL(targetName, targetKind, entitySlug string) string

	// ParseSourceCode extracts just the source code from a page body.
	ParseSourceCode(body []byte) (string, error)
}

Source defines the contract for a documentation source adapter. Each documentation framework (WordPress, Laravel, React, etc.) implements this interface. The crawler uses it generically.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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