# `PtcRunner.SubAgent.TypeExtractor`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/sub_agent/type_extractor.ex#L1)

Extract signature and description from Elixir function @spec and @doc.

Converts Elixir type specifications to PTC signature format for automatic
tool definition. Extraction requires compiled documentation and only works
for named functions (not anonymous).

## Limitations

- Requires docs to be compiled (not available in releases without `--docs`)
- Only works for named functions (not anonymous)
- @spec conversion is best-effort; explicit signatures are more precise
- Unsupported types fall back to `:any` with warning

## Examples

    # Anonymous function - cannot extract
    iex> PtcRunner.SubAgent.TypeExtractor.extract(fn x -> x end)
    {:ok, {nil, nil}}

# `extract`

```elixir
@spec extract(function()) :: {:ok, {String.t() | nil, String.t() | nil}}
```

Extract signature and description from a function reference.

Returns `{:ok, {signature, description}}` where both may be `nil` if extraction
is not possible. Never returns an error - falls back to `{nil, nil}` when
extraction fails.

## Examples

    iex> {:ok, {signature, _description}} = PtcRunner.SubAgent.TypeExtractor.extract(&String.upcase/1)
    iex> is_binary(signature) or is_nil(signature)
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
