Documentation
¶
Overview ¶
Package python is the Python source-language plugin: packages and imports, the facts `analyze` scores, the PyPI-to-Go table lookup, and the exported functions and classes of a unit with type hints mapped into the TS-like type dialect. It is the counterpart of rust-anything's `lang/python.rs` and the Python parts of `lang/effects.rs`.
It parses with tree-sitter (`internal/syntax`), as the reference does.
Index ¶
- func FileExports(path string, source []byte) ([]lang.Fn, []lang.Class)
- func SkipDirs() []string
- func ToTSType(hint string) string
- type Observed
- type Plugin
- func (Plugin) Detect(root string) int
- func (Plugin) Discover(root string) (*lang.Workspace, error)
- func (Plugin) Exports(root, unit string) (*core.UnitExports, error)
- func (Plugin) Extensions() []string
- func (Plugin) Lang() core.Lang
- func (Plugin) Lookup(dep string) (modules.Match, bool)
- func (Plugin) Name() string
- func (Plugin) NeedsHost(platforms []lang.Platform) bool
- func (Plugin) Registry() string
- func (Plugin) Resolve(from, spec string, ix *lang.Index) lang.Resolution
- func (Plugin) Scan(path, text string) *lang.FileFacts
- func (Plugin) SkipsDir(root, dir string) bool
- func (Plugin) UnitBridge(portable bool) core.BridgeKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExports ¶
FileExports reads the public module-level functions and classes of one file's text, before they are sorted into exports and kept. The tests and `profile` read through it.
Types ¶
type Observed ¶
Observed is what a function does that the recording sees: the parameters it changes in place, and whether it writes to standard output. Judged from the text; a miss is caught by `diff`, which compares the arguments after the call whatever this says.
type Plugin ¶
type Plugin struct{}
Plugin is Python as a source language. It implements core.Plugin and lang.Analyzer.
func (Plugin) Detect ¶
Detect scores a repository: a Python manifest at the root beats everything (the reference detects by manifest first, Python before `package.json`), otherwise the number of `.py` files a standard walk finds.
func (Plugin) Exports ¶
func (Plugin) Exports(root, unit string) (*core.UnitExports, error)
Exports reads one unit (a unit id from `analyze`, or a source file, relative to root) and sorts what it offers into what can cross the bridge and what stays in the original.
func (Plugin) Extensions ¶
Extensions are the extensions of Python source files.
func (Plugin) Lookup ¶
Lookup is the Go counterpart of a PyPI package (or import name), when the table knows it.
func (Plugin) Resolve ¶
Resolve says where an import of `from` points. A standard-library module is ToPlatform.
func (Plugin) SkipsDir ¶
SkipsDir reports whether Python discovery skips the folder dir (relative to root, with `/`) because of its name: a dependency tree, a virtual environment, build output.
func (Plugin) UnitBridge ¶
func (Plugin) UnitBridge(portable bool) core.BridgeKind
UnitBridge: every Python unit reaches Go through the C shared library.