Search documentation of Ragex

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

View Source

Report generation for refactoring operations.

Generates comprehensive reports in multiple formats (Markdown, JSON, HTML) combining statistics, diffs, conflicts, and warnings from refactoring operations.

## Summary

### Types

report_data()
report_format()
stats()
timing_info()

### Functions

create_report_data(refactor_result, diffs, conflicts \\ [])

Creates a summary report data structure from refactor result and diffs.

generate(data, format \\ :markdown, opts \\ [])

Generates a refactoring report in the specified format.

save_report(report, output_path)

Saves a report to a file.

## Types

# report_data()

    @type report_data() :: %{
      operation: atom(),
      status: :success | :failure,
      stats: stats(),
      diffs: [map()],
      conflicts: [Ragex.Editor.Conflict.conflict()],
      warnings: [String.t()],
      timing: timing_info()
    }

# report_format()

    @type report_format() :: :markdown | :json | :html

# stats()

    @type stats() :: %{
      files_modified: non_neg_integer(),
      lines_added: non_neg_integer(),
      lines_removed: non_neg_integer(),
      functions_affected: non_neg_integer()
    }

# timing_info()

    @type timing_info() :: %{
      start_time: DateTime.t(),
      end_time: DateTime.t(),
      duration_ms: non_neg_integer()
    }

## Functions

# create_report_data(refactor_result, diffs, conflicts \\ [])

    @spec create_report_data(map(), [map()], [Ragex.Editor.Conflict.conflict()]) ::
      report_data()

Creates a summary report data structure from refactor result and diffs.

## Parameters

- `refactor_result`: Result from a refactoring operation
- `diffs`: List of diff results from Diff.generate/3
- `conflicts`: Optional list of conflicts from Conflict module

## Returns

- Report data map

# generate(data, format \\ :markdown, opts \\ [])

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

Generates a refactoring report in the specified format.

## Parameters

- `data`: Report data including operation details, stats, diffs, and conflicts
- `format`: Output format (:markdown, :json, or :html)
- `opts`: Options
  - `:include_diffs` - Include full diffs (default: true)
  - `:include_conflicts` - Include conflict details (default: true)
  - `:include_timing` - Include timing information (default: true)

## Returns

- `{:ok, report_string}` with formatted report
- `{:error, reason}` on failure

# save_report(report, output_path)

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

Saves a report to a file.

## Parameters

- `report`: Generated report string
- `output_path`: File path to save report

## Returns

- `:ok` on success
- `{:error, reason}` on failure