Documentation
¶
Overview ¶
Package python provides a documentation source adapter that reads Python source code from a local checkout of a Python framework repository (Django, Flask, FastAPI, etc.). It parses raw Python source via tree-sitter to extract classes, functions, async functions, methods, properties, and docstrings without making any network calls during parsing.
Index ¶
- func NewAiohttpFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewBottleFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewCeleryFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewClickFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewDashFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewDjangoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewFalconFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewFastAPIFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewFlaskFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewLitestarFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewMasoniteFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewNumPyFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewPandasFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewPydanticFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewPyramidFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewPytestFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewQuartFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewReflexFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewRequestsFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewRobynFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewSQLAlchemyFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewSanicFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewScikitLearnFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewStarletteFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewStdlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- func NewTornadoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)
- type Config
- type Option
- type PythonSource
- func (s *PythonSource) DetectWrapper(method *source.Method) (bool, string, string)
- func (s *PythonSource) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)
- func (s *PythonSource) ID() string
- func (s *PythonSource) Meta() source.LibraryMeta
- func (s *PythonSource) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)
- func (s *PythonSource) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)
- func (s *PythonSource) ParseSourceCode(entityID string, content []byte) (string, error)
- func (s *PythonSource) ResolveWrapperURL(targetName, targetKind, entitySlug string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAiohttpFactory ¶
NewAiohttpFactory creates a Source for the aiohttp async HTTP framework.
func NewBottleFactory ¶
NewBottleFactory creates a Source for the Bottle micro framework.
func NewCeleryFactory ¶
NewCeleryFactory creates a Source for the Celery task queue.
func NewClickFactory ¶
NewClickFactory creates a Source for the Click CLI framework.
func NewDashFactory ¶
NewDashFactory creates a Source for the Dash analytical web framework.
func NewDjangoFactory ¶
NewDjangoFactory creates a Source for the Django web framework.
func NewFalconFactory ¶
NewFalconFactory creates a Source for the Falcon REST framework.
func NewFastAPIFactory ¶
NewFastAPIFactory creates a Source for the FastAPI framework.
func NewFlaskFactory ¶
NewFlaskFactory creates a Source for the Flask microframework.
func NewLitestarFactory ¶
NewLitestarFactory creates a Source for the Litestar ASGI framework.
func NewMasoniteFactory ¶
NewMasoniteFactory creates a Source for the Masonite framework.
func NewNumPyFactory ¶
NewNumPyFactory creates a Source for the NumPy library.
func NewPandasFactory ¶
NewPandasFactory creates a Source for the Pandas library.
func NewPydanticFactory ¶
NewPydanticFactory creates a Source for the Pydantic data validation library.
func NewPyramidFactory ¶
NewPyramidFactory creates a Source for the Pyramid web framework.
func NewPytestFactory ¶
NewPytestFactory creates a Source for the pytest testing framework.
func NewQuartFactory ¶
NewQuartFactory creates a Source for the Quart async framework.
func NewReflexFactory ¶
NewReflexFactory creates a Source for the Reflex full-stack web framework.
func NewRequestsFactory ¶
NewRequestsFactory creates a Source for the Requests library.
func NewRobynFactory ¶
NewRobynFactory creates a Source for the Robyn async framework.
func NewSQLAlchemyFactory ¶
NewSQLAlchemyFactory creates a Source for the SQLAlchemy ORM.
func NewSanicFactory ¶
NewSanicFactory creates a Source for the Sanic web framework.
func NewScikitLearnFactory ¶
NewScikitLearnFactory creates a Source for the scikit-learn machine learning library.
func NewStarletteFactory ¶
NewStarletteFactory creates a Source for the Starlette ASGI framework.
func NewStdlibFactory ¶
NewStdlibFactory creates a Source for the Python standard library.
func NewTornadoFactory ¶
NewTornadoFactory creates a Source for the Tornado web framework.
Types ¶
type Config ¶
type Config struct {
// LibraryID is the canonical identifier (e.g., "/python/django").
LibraryID string
// Name is the display name for the library (e.g., "Django Reference").
Name string
// Description is the library description.
Description string
// SourceURL is the GitHub URL for the framework (e.g., "https://github.com/django/django").
SourceURL string
// Version is the version string for the library.
Version string
// TrustScore is the relevance trust score (0-1).
TrustScore float64
// SourceRoots are the directory paths relative to the repo root that
// contain the framework's source code (e.g., ["django"] for Django,
// ["flask"] for Flask, ["src/fastapi"] for FastAPI).
SourceRoots []string
}
Config holds the framework-specific configuration for a PythonSource.
type Option ¶
type Option func(*PythonSource)
Option customises a PythonSource at construction time.
type PythonSource ¶
type PythonSource struct {
// contains filtered or unexported fields
}
PythonSource is a documentation source adapter that reads Python source code from a local repository checkout. It is configurable for any Python framework (Django, Flask, FastAPI, etc.).
func New ¶
func New(repoPath string, cfg Config, opts ...Option) *PythonSource
New constructs a new PythonSource for the given local repository path and framework configuration.
func (*PythonSource) DetectWrapper ¶
DetectWrapper analyzes a method's source code for wrapper patterns.
func (*PythonSource) DiscoverEntities ¶
func (s *PythonSource) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)
DiscoverEntities walks the local repository and returns a sorted list of entity identifiers in the form "filepath#EntityName".
func (*PythonSource) Meta ¶
func (s *PythonSource) Meta() source.LibraryMeta
Meta returns metadata for the library record.
func (*PythonSource) ParseEntity ¶
func (s *PythonSource) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)
ParseEntity parses a single entity from file content, identified by entityID. The entityID is of the form "filepath#EntityName".
func (*PythonSource) ParseMethod ¶
func (s *PythonSource) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)
ParseMethod parses a single method/function from file content. The methodID is of the form "filepath#ClassName.methodName".
func (*PythonSource) ParseSourceCode ¶
func (s *PythonSource) ParseSourceCode(entityID string, content []byte) (string, error)
ParseSourceCode extracts just the source code of a specific entity or method from file content, using the fragment in the identifier.
func (*PythonSource) ResolveWrapperURL ¶
func (s *PythonSource) ResolveWrapperURL(targetName, targetKind, entitySlug string) string
ResolveWrapperURL constructs the identifier to fetch the wrapped target's source.