typescript

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package typescript provides a Source interface implementation for parsing TypeScript source code from any TypeScript-based library (Angular, NestJS, RxJS, Zod, etc.). It uses tree-sitter for AST parsing and the shared JSDoc parser for documentation extraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdonisFactory

func NewAdonisFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewAdonisFactory creates a Source for the AdonisJS framework.

func NewAnalogFactory

func NewAnalogFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewAnalogFactory creates a Source for the Analog framework.

func NewAngularFactory

func NewAngularFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewAngularFactory creates a Source for the Angular framework.

func NewAstroFactory

func NewAstroFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewAstroFactory creates a Source for the Astro framework.

func NewBlitzFactory

func NewBlitzFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewBlitzFactory creates a Source for the Blitz.js framework.

func NewDateFnsFactory

func NewDateFnsFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDateFnsFactory creates a Source for the date-fns library.

func NewDrizzleFactory

func NewDrizzleFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDrizzleFactory creates a Source for the Drizzle ORM.

func NewEffectFactory

func NewEffectFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewEffectFactory creates a Source for the Effect library.

func NewElectronFactory

func NewElectronFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewElectronFactory creates a Source for the Electron framework.

func NewElysiaFactory

func NewElysiaFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewElysiaFactory creates a Source for the Elysia framework.

func NewFeathersFactory

func NewFeathersFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFeathersFactory creates a Source for the Feathers framework.

func NewFoalFactory

func NewFoalFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFoalFactory creates a Source for the FoalTS framework.

func NewFreshFactory

func NewFreshFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFreshFactory creates a Source for the Fresh framework.

func NewHonoFactory

func NewHonoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewHonoFactory creates a Source for the Hono web framework.

func NewJestFactory

func NewJestFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewJestFactory creates a Source for the Jest testing framework.

func NewNestJSFactory

func NewNestJSFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewNestJSFactory creates a Source for the NestJS framework.

func NewNextJSFactory

func NewNextJSFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewNextJSFactory creates a Source for the Next.js framework.

func NewNitroFactory

func NewNitroFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewNitroFactory creates a Source for the Nitro server toolkit.

func NewNuxtFactory

func NewNuxtFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewNuxtFactory creates a Source for the Nuxt framework.

func NewPrismaFactory

func NewPrismaFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewPrismaFactory creates a Source for the Prisma ORM.

func NewRxJSFactory

func NewRxJSFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRxJSFactory creates a Source for the RxJS reactive extensions library.

func NewSocketIOFactory

func NewSocketIOFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSocketIOFactory creates a Source for the Socket.IO library.

func NewSolidFactory

func NewSolidFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSolidFactory creates a Source for the SolidJS reactive UI library. Replaces Wasp, whose compiler is written in Haskell and cannot be indexed by the TypeScript adapter.

func NewStdlibFactory

func NewStdlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewStdlibFactory creates a Source for the TypeScript standard type definitions.

func NewStrapiFactory

func NewStrapiFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewStrapiFactory creates a Source for the Strapi headless CMS.

func NewTRPCFactory

func NewTRPCFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewTRPCFactory creates a Source for the tRPC framework.

func NewTypeORMFactory

func NewTypeORMFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewTypeORMFactory creates a Source for the TypeORM database framework.

func NewVitestFactory

func NewVitestFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewVitestFactory creates a Source for the Vitest testing framework.

func NewZodFactory

func NewZodFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewZodFactory creates a Source for the Zod schema validation library.

Types

type Config

type Config struct {
	// LibraryID is the canonical library ID (e.g., "typescript/angular").
	LibraryID string

	// Name is the human-readable library name (e.g., "Angular").
	Name string

	// Description is a brief library description.
	Description string

	// SourceURL is the canonical URL (e.g., "https://github.com/angular/angular").
	SourceURL string

	// Owner is the GitHub repository owner.
	Owner string

	// Repo is the GitHub repository name.
	Repo string

	// SourceDirs are relative directories within the repo to scan.
	// If empty, defaults to ["src/"].
	SourceDirs []string

	// ExcludeDirs are directory names to skip during discovery.
	// Always includes: node_modules, test, tests, __tests__, dist, build, .git
	ExcludeDirs []string

	// IncludeDeclarationFiles controls whether .d.ts files are indexed.
	// Useful for type-only libraries.
	IncludeDeclarationFiles bool
}

Config holds the configuration for a TypeScript source adapter. Each TypeScript library (Angular, NestJS, RxJS, etc.) provides its own Config with appropriate repository and directory settings.

type Option

type Option func(*Source)

Option customises a Source at construction time.

func WithRef

func WithRef(ref string) Option

WithRef sets the git ref (tag or branch) for source-code links.

type Source

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

Source is a documentation source adapter that reads TypeScript source code from a local clone of a GitHub repository. It uses tree-sitter for AST parsing and JSDoc for documentation extraction.

func New

func New(cfg Config, repoPath string, opts ...Option) *Source

New constructs a new TypeScript Source for the given config and local repo path.

func (*Source) DetectWrapper

func (s *Source) DetectWrapper(method *source.Method) (bool, string, string)

DetectWrapper analyzes a method's source code for wrapper patterns.

func (*Source) DiscoverEntities

func (s *Source) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)

DiscoverEntities walks the local repository and returns identifiers for all exported TypeScript entities. The fetch parameter is unused -- all discovery reads files locally.

func (*Source) ID

func (s *Source) ID() string

ID returns the canonical library ID.

func (*Source) Meta

func (s *Source) Meta() source.LibraryMeta

Meta returns metadata for the library record.

func (*Source) ParseEntity

func (s *Source) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)

ParseEntity parses a single entity from file content.

func (*Source) ParseMethod

func (s *Source) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)

ParseMethod parses a single method from file content.

func (*Source) ParseSourceCode

func (s *Source) ParseSourceCode(entityID string, content []byte) (string, error)

ParseSourceCode extracts just the source code of a specific entity or method from file content.

func (*Source) ResolveWrapperURL

func (s *Source) ResolveWrapperURL(targetName, targetKind, entitySlug string) string

ResolveWrapperURL constructs an identifier to fetch the wrapped target's source.

Jump to

Keyboard shortcuts

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