Skip to content

Commit

Permalink
Refs: #171; Typespecs for Earmark.Helpers.AttrParser
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDober committed Apr 3, 2018
1 parent 3f65b48 commit d40e81c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/earmark/helpers/attr_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ defmodule Earmark.Helpers.AttrParser do
import Earmark.Helpers.StringHelpers, only: [ behead: 2 ]
import Earmark.Message, only: [add_message: 2]

alias Earmark.Context
alias Earmark.Options

@typep errorlist :: list(String.t)

@spec parse_attrs(any(), String.t, number()) :: {Options.t, map()}
@spec parse_attrs(Options.t, String.t, non_neg_integer) :: {Options.t, map()}
def parse_attrs(context, attrs, lnb) do
{ attrs, errors } = _parse_attrs(%{}, attrs, [], lnb)
{ add_errors(context, errors, lnb), attrs }
end

@spec _parse_attrs( map(), String.t, errorlist, number() ) :: {map(), errorlist}
@spec _parse_attrs( map(), String.t, errorlist, number() ) :: {Options.t, errorlist}
defp _parse_attrs(dict, attrs, errors, lnb) do
cond do
Regex.match?(~r{^\s*$}, attrs) -> {dict, errors}
Expand Down Expand Up @@ -55,6 +54,7 @@ defmodule Earmark.Helpers.AttrParser do
end
end

@spec add_errors( Options.t, errorlist, non_neg_integer ) :: Options.t
defp add_errors(context, [], _lnb), do: context
defp add_errors(context, errors, lnb), do: add_message(context, {:warning, lnb, "Illegal attributes #{inspect errors} ignored in IAL"})

Expand Down

0 comments on commit d40e81c

Please sign in to comment.