Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typespec fixes + Fix to Earmark.Context.clear/1 #165

Merged
merged 4 commits into from
Nov 26, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/earmark/context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ defmodule Earmark.Context do
use Earmark.Types
import Earmark.Helpers

@type t :: %__MODULE__{
options: Earmark.Options.t,
links: map(),
rules: Keyword.t(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this can be nil as well?

footnotes: map(),
value: String.t | [String.t]
}

defstruct options: %Earmark.Options{},
links: Map.new,
rules: nil,
Expand Down Expand Up @@ -33,7 +41,7 @@ defmodule Earmark.Context do
def clear(%__MODULE__{} = ctx) do
ctx
|> set_value([])
put_in(ctx.options.messages, [])
|> put_in([:options, :messages], [])
end

@doc false
Expand Down
4 changes: 2 additions & 2 deletions lib/earmark/helpers/attr_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Earmark.Helpers.AttrParser do

@type errorlist :: list(String.t)

@spec parse_attrs(Context.t, String.t, number()) :: {Map.t, errorlist}
@spec parse_attrs(Context.t, String.t, number()) :: {map, errorlist}
def parse_attrs(context, attrs, lnb) do
{ attrs, errors } = _parse_attrs(%{}, attrs, [], lnb)
{ add_errors(context, errors, lnb), attrs }
Expand Down Expand Up @@ -55,5 +55,5 @@ defmodule Earmark.Helpers.AttrParser do

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"})

end
2 changes: 2 additions & 0 deletions lib/earmark/options.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
defmodule Earmark.Options do

@type t :: %__MODULE__{}

# What we use to render
defstruct renderer: Earmark.HtmlRenderer,
# Inline style options
Expand Down
2 changes: 1 addition & 1 deletion lib/earmark/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Earmark.Types do
quote do
@type token :: {atom, String.t}
@type tokens :: list(token)
@type numbered_line :: %{line: String.t, lnb: number}
@type numbered_line :: %{required(:line) => String.t, required(:lnb) => number, optional(:inside_code) => String.t}
@type message_type :: :warning | :error
@type message :: {message_type, number, String.t}
@type maybe(t) :: t | nil
Expand Down