Skip to content

Commit db0780e

Browse files
NSHkrNSHkr
authored andcommitted
fix code style
1 parent 7ff58f5 commit db0780e

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

lib/json_remedy.ex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ defmodule JsonRemedy do
55
JsonRemedy uses advanced binary pattern matching and functional composition
66
to intelligently repair malformed JSON strings while achieving superior performance.
77
8+
This module provides the main API for JSON repair functionality. It supports
9+
multiple repair strategies and can handle various types of malformed JSON.
10+
11+
See `@type json_value` for the type specification of parsed JSON values.
12+
See `@type repair_result` for the main return type specifications.
13+
814
## Examples
915
1016
iex> JsonRemedy.repair(~s|{name: "Alice", age: 30, active: True}|)
@@ -21,8 +27,12 @@ defmodule JsonRemedy do
2127
alias JsonRemedy.Combinators
2228
alias JsonRemedy.Pipeline
2329

24-
@type repair_result :: {:ok, term()} | {:error, String.t()}
25-
@type repair_result_with_logs :: {:ok, term(), [String.t()]} | {:error, String.t()}
30+
# Type definitions
31+
@type json_value ::
32+
nil | boolean() | number() | String.t() | [json_value()] | %{String.t() => json_value()}
33+
@type repair_log :: String.t()
34+
@type repair_result :: {:ok, json_value()} | {:error, String.t()}
35+
@type repair_result_with_logs :: {:ok, json_value(), [repair_log()]} | {:error, String.t()}
2636
@type strategy :: :binary_patterns | :combinators | :streaming
2737
@type option :: {:logging, boolean()} | {:strategy, strategy()} | {:strict, boolean()}
2838

lib/json_remedy/binary_parser.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ defmodule JsonRemedy.BinaryParser do
55
This module uses Elixir's advanced binary pattern matching to parse and repair
66
JSON without character-by-character iteration. Each function clause matches
77
specific binary patterns, making parsing extremely efficient.
8+
9+
See `@type parse_context` for the context structure used during parsing.
10+
See `@type parse_result` for the intermediate parsing result type.
11+
See `@type repair_result` for the final repair result type.
812
"""
913

14+
# Type definitions
15+
@type json_value ::
16+
nil | boolean() | number() | String.t() | [json_value()] | %{String.t() => json_value()}
17+
@type repair_log :: String.t()
1018
@type parse_context :: %{
11-
repairs: [String.t()],
19+
repairs: [repair_log()],
1220
position: non_neg_integer(),
1321
strict: boolean()
1422
}
15-
16-
@type parse_result :: {term(), binary(), parse_context()}
17-
@type repair_result :: {:ok, term()} | {:ok, term(), [String.t()]} | {:error, String.t()}
23+
@type parse_result :: {json_value(), binary(), parse_context()}
24+
@type repair_result ::
25+
{:ok, json_value()} | {:ok, json_value(), [repair_log()]} | {:error, String.t()}
1826

1927
@doc """
2028
Main entry point for binary pattern matching repair.

lib/json_remedy/combinators.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ defmodule JsonRemedy.Combinators do
66
that can each handle and repair specific syntax issues. While more
77
elegant than direct parsing, it's currently a placeholder for future
88
implementation.
9+
10+
See `@type repair_result` for the return type specification.
911
"""
1012

11-
@type repair_result :: {:ok, term()} | {:ok, term(), [String.t()]} | {:error, String.t()}
13+
# Type definitions
14+
@type json_value ::
15+
nil | boolean() | number() | String.t() | [json_value()] | %{String.t() => json_value()}
16+
@type repair_log :: String.t()
17+
@type repair_result ::
18+
{:ok, json_value()} | {:ok, json_value(), [repair_log()]} | {:error, String.t()}
1219

1320
@doc """
1421
Repairs JSON using parser combinator approach.

lib/json_remedy/pipeline.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ defmodule JsonRemedy.Pipeline do
55
This approach processes JSON repair as a stream of transformations,
66
making it suitable for large files or real-time processing.
77
Currently a placeholder for future implementation.
8+
9+
See `@type repair_result` for the return type specification.
810
"""
911

10-
@type repair_result :: {:ok, term()} | {:ok, term(), [String.t()]} | {:error, String.t()}
12+
# Type definitions
13+
@type json_value ::
14+
nil | boolean() | number() | String.t() | [json_value()] | %{String.t() => json_value()}
15+
@type repair_log :: String.t()
16+
@type repair_result ::
17+
{:ok, json_value()} | {:ok, json_value(), [repair_log()]} | {:error, String.t()}
1118

1219
@doc """
1320
Repairs JSON using stream processing approach.

0 commit comments

Comments
 (0)