python

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: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAiohttpFactory

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

NewAiohttpFactory creates a Source for the aiohttp async HTTP framework.

func NewBottleFactory

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

NewBottleFactory creates a Source for the Bottle micro framework.

func NewCeleryFactory

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

NewCeleryFactory creates a Source for the Celery task queue.

func NewClickFactory

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

NewClickFactory creates a Source for the Click CLI framework.

func NewDashFactory

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

NewDashFactory creates a Source for the Dash analytical web framework.

func NewDjangoFactory

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

NewDjangoFactory creates a Source for the Django web framework.

func NewFalconFactory

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

NewFalconFactory creates a Source for the Falcon REST framework.

func NewFastAPIFactory

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

NewFastAPIFactory creates a Source for the FastAPI framework.

func NewFlaskFactory

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

NewFlaskFactory creates a Source for the Flask microframework.

func NewLitestarFactory

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

NewLitestarFactory creates a Source for the Litestar ASGI framework.

func NewMasoniteFactory

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

NewMasoniteFactory creates a Source for the Masonite framework.

func NewNumPyFactory

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

NewNumPyFactory creates a Source for the NumPy library.

func NewPandasFactory

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

NewPandasFactory creates a Source for the Pandas library.

func NewPydanticFactory

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

NewPydanticFactory creates a Source for the Pydantic data validation library.

func NewPyramidFactory

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

NewPyramidFactory creates a Source for the Pyramid web framework.

func NewPytestFactory

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

NewPytestFactory creates a Source for the pytest testing framework.

func NewQuartFactory

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

NewQuartFactory creates a Source for the Quart async framework.

func NewReflexFactory

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

NewReflexFactory creates a Source for the Reflex full-stack web framework.

func NewRequestsFactory

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

NewRequestsFactory creates a Source for the Requests library.

func NewRobynFactory

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

NewRobynFactory creates a Source for the Robyn async framework.

func NewSQLAlchemyFactory

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

NewSQLAlchemyFactory creates a Source for the SQLAlchemy ORM.

func NewSanicFactory

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

NewSanicFactory creates a Source for the Sanic web framework.

func NewScikitLearnFactory

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

NewScikitLearnFactory creates a Source for the scikit-learn machine learning library.

func NewStarletteFactory

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

NewStarletteFactory creates a Source for the Starlette ASGI framework.

func NewStdlibFactory

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

NewStdlibFactory creates a Source for the Python standard library.

func NewTornadoFactory

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

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.

func WithRef

func WithRef(ref string) Option

WithRef sets the git ref (tag or branch) for source-code links, e.g. WithRef("4.2") produces links under .../blob/4.2/.

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

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

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) ID

func (s *PythonSource) ID() string

ID returns the canonical library ID.

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.

Jump to

Keyboard shortcuts

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