Search documentation of Ragex

# Ragex.Editor.Formatter (Ragex v0.4.0)

View Source

Automatic code formatting integration.

Provides language-specific formatters that can be run after successful edits. Formatters are detected based on file extension and project structure.

## Summary

### Functions

available?(path, opts \\ [])

Checks if a formatter is available for the given file or language.

format(path, opts \\ [])

Formats a file using the appropriate language formatter.

## Functions

# available?(path, opts \\ [])

    @spec available?(
      String.t(),
      keyword()
    ) :: boolean()

Checks if a formatter is available for the given file or language.

## Examples

    iex> Formatter.available?("lib/module.ex")
    true

    iex> Formatter.available?("file.txt")
    false

# format(path, opts \\ [])

    @spec format(
      String.t(),
      keyword()
    ) :: :ok | {:error, term()}

Formats a file using the appropriate language formatter.

## Parameters

- `path`: Path to the file to format
- `opts`: Options
  - `:language` - Explicit language override
  - `:formatter` - Explicit formatter command

## Returns

- `:ok` if formatting succeeded or no formatter available
- `{:error, reason}` if formatting failed

## Examples

    iex> Formatter.format("lib/module.ex")
    :ok

    iex> Formatter.format("script", language: :python)
    :ok