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

Fix typespecs #46

Open
wants to merge 1 commit into
base: feature/extends-options
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions lib/sparkline_svg/core.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule SparklineSvg.Core do
@typedoc false
@typep min_max :: {number(), number()}

@typedoc "Internal representation of a x value of a point"
@typedoc "Internal representation of an x value of a point"
@type x :: number()

@typedoc "Internal representation of a y value of a point"
Expand Down Expand Up @@ -105,7 +105,12 @@ defmodule SparklineSvg.Core do
end)
end

@spec calc_resize_ref_lines(SparklineSvg.ref_lines(), points(), min_max(), SparklineSvg.opts()) ::
@spec calc_resize_ref_lines(
SparklineSvg.ref_lines(),
Datapoint.points(),
min_max(),
SparklineSvg.opts()
) ::
SparklineSvg.ref_lines()
defp calc_resize_ref_lines(ref_lines, datapoints, min_max_y, options) do
ref_lines
Expand Down
7 changes: 4 additions & 3 deletions lib/sparkline_svg/datapoint.ex
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
defmodule SparklineSvg.Datapoint do
@moduledoc false

alias SparklineSvg.Type
alias SparklineSvg.Core
alias SparklineSvg.Datapoint
alias SparklineSvg.Type

@typedoc false
@type points :: list(Datapoint.t())

@typedoc false
@type t :: %Datapoint{
source: SparklineSvg.datapoints(),
computed: points()
source: Core.point(),
computed: Core.point()
}
@enforce_keys [:source, :computed]
defstruct [:source, :computed]
Expand Down
5 changes: 3 additions & 2 deletions lib/sparkline_svg/reference_line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defmodule SparklineSvg.ReferenceLine do
alias SparklineSvg.ReferenceLine

@typedoc "A reference line function."
@type ref_line_function :: (Datapoint.t() -> Core.y())
@type ref_line_function :: (Datapoint.points() -> Core.y())

@typedoc false
@type t :: %ReferenceLine{
Expand Down Expand Up @@ -177,7 +177,7 @@ defmodule SparklineSvg.ReferenceLine do
"""

@doc since: "0.4.0"
@spec median(Datapoint.t()) :: Core.y()
@spec median(Datapoint.points()) :: Core.y()
def median(datapoints) do
percentile(50).(datapoints)
end
Expand Down Expand Up @@ -207,6 +207,7 @@ defmodule SparklineSvg.ReferenceLine do
end

@spec find_interpolated_value(Datapoint.t(), number()) :: Core.y()
@spec find_interpolated_value(Datapoint.points(), number()) :: Core.y()
defp find_interpolated_value(_datapoints, index) when index < 1, do: 0

defp find_interpolated_value(datapoints, index) do
Expand Down
Loading