First pass at uniformed types, specs and docs

- spec public functions (skipping controllers, views, live views and
components)
- use types instead of explanations in docs
- remove redundant docs
- fix typos
This commit is contained in:
Claudio Ortolina
2026-03-06 08:33:11 +00:00
parent 99e30d5fdf
commit 7cf9b4e7f8
81 changed files with 652 additions and 300 deletions
+8
View File
@@ -3,6 +3,12 @@ defmodule LastFm.Session do
defstruct [:name, :key, :pro]
@type t :: %__MODULE__{
name: String.t() | nil,
key: String.t() | nil,
pro: boolean() | nil
}
Record.defrecord(
:xmlAttribute,
Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
@@ -32,6 +38,7 @@ defmodule LastFm.Session do
pro: true
}
"""
@spec parse(String.t()) :: t()
def parse(xml_string) do
doc = scan(xml_string)
@@ -77,6 +84,7 @@ defmodule LastFm.Session do
:xmerl_xpath.string(to_charlist(path), node)
end
@spec text(tuple() | nil) :: String.t() | nil
def text(node), do: node |> xpath(~c"./text()") |> extract_text()
defp extract_text([xmlText(value: value)]), do: List.to_string(value)