SnakeBridge.Config.Library (SnakeBridge v0.15.1)

Copy Markdown View Source

Configuration struct for a single Python library binding.

Options

  • :generate - Controls which symbols are generated:
    • :used (default) - Only generate wrappers for symbols detected in your code
    • :all - Generate wrappers for ALL public symbols in the Python module
  • :module_mode - Controls which Python submodules are generated when generate: :all:
    • :root / :light / :top - Only the root module
    • :exports / :api - Only the root module, plus submodules explicitly exported by the root module via __all__ (avoids walking large internal trees)
    • :public / :standard - Discover submodules and keep public API modules
    • :explicit - Discover submodules and keep only modules/packages that explicitly define __all__ (smallest “discover” mode; use module_include for overrides)
    • :docs / :manifest - Generate a docs-defined public surface from a manifest file
    • :all / :nuclear - Discover all submodules (including private)
    • {:only, ["linalg", "fft"]} - Explicit submodule allowlist
  • :submodules - When true, introspect all submodules (can generate thousands of files)
  • :public_api - When true with submodules: true, only include modules with explicit public API (__all__ defined or classes defined in the module). This filters out internal implementation modules, typically reducing generated files by 90%+.
  • :module_include - Extra submodules to include (relative to the library root)
  • :module_exclude - Submodules to exclude (relative to the library root)
  • :module_depth - Limit discovery depth (e.g. 1 = only direct children)
  • :docs_url - Explicit documentation URL for third-party libraries
  • :docs_manifest - Path to a SnakeBridge docs manifest JSON file (used with module_mode: :docs)
  • :docs_profile - Profile key inside docs_manifest (:summary, :full, or custom string)
  • :class_method_scope - Controls how class methods are discovered during introspection:
    • :all (default) - include inherited methods (can be huge for tensor-like bases)
    • :defined - only methods defined on the class itself (plus __init__)
  • :max_class_methods - Guardrail for class method enumeration. When class_method_scope: :all would exceed this limit, SnakeBridge falls back to :defined for that class.
  • :on_not_found - Behavior when a requested symbol is not present in the current Python env:
    • :error - fail compilation (recommended for generate: :used)
    • :stub - generate deterministic stubs and continue (recommended for docs-derived surfaces)

Summary

Types

class_method_scope()

@type class_method_scope() :: :all | :defined

generate_mode()

@type generate_mode() :: :all | :used

module_mode()

@type module_mode() ::
  :root | :exports | :public | :explicit | :docs | :all | {:only, [String.t()]}

on_not_found()

@type on_not_found() :: :error | :stub

t()

@type t() :: %SnakeBridge.Config.Library{
  class_method_scope: class_method_scope() | nil,
  docs_manifest: String.t() | nil,
  docs_profile: String.t() | nil,
  docs_url: String.t() | nil,
  exclude: [String.t()],
  extras: [String.t()],
  generate: generate_mode(),
  include: [String.t()],
  max_class_methods: non_neg_integer() | nil,
  min_signature_tier: atom() | String.t() | nil,
  module_depth: pos_integer() | nil,
  module_exclude: [String.t()],
  module_include: [String.t()],
  module_mode: module_mode() | nil,
  module_name: module(),
  name: atom(),
  on_not_found: on_not_found() | nil,
  public_api: boolean(),
  pypi_package: String.t() | nil,
  python_name: String.t(),
  signature_sources: [atom() | String.t()] | nil,
  streaming: [String.t()],
  strict_signatures: boolean() | nil,
  stub_search_paths: [String.t()] | nil,
  stubgen: keyword() | nil,
  submodules: boolean(),
  typeshed_path: String.t() | nil,
  use_typeshed: boolean() | nil,
  version: String.t() | :stdlib | nil
}