Skip to content

Commit

Permalink
Add some @spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jul 27, 2018
1 parent 16d67b2 commit 5f0062a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/atomex.ex
Expand Up @@ -11,10 +11,12 @@ defmodule Atomex do
- feed: an `Atomex.Feed`
"""
@spec generate_document(Atomex.Feed.t()) :: binary()
def generate_document(feed) do
XmlBuilder.doc(feed)
end

@spec version() :: binary()
def version do
elem(:application.get_key(:atomex, :vsn), 1)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/atomex/entry.ex
Expand Up @@ -3,6 +3,8 @@ defmodule Atomex.Entry do
A feed entry
"""

@type t :: list()

import XmlBuilder
alias Atomex.Types.{Person, Link, Text, Content, Category}

Expand Down
6 changes: 6 additions & 0 deletions lib/atomex/feed.ex
Expand Up @@ -3,12 +3,15 @@ defmodule Atomex.Feed do
Represent an Atom feed. Embed many `Atomex.Entry`
"""

@type t :: list()

import XmlBuilder
alias Atomex.Types.{Person, Link, Text, Category}

@doc """
Create a new feed
"""
@spec new(binary(), DateTime.t, binary(), binary()) :: Atomex.Feed.t
def new(id, last_update_datetime, title, title_type \\ "text") do
[
{:id, nil, id},
Expand Down Expand Up @@ -55,18 +58,21 @@ defmodule Atomex.Feed do
@doc """
Add an author to the feed. See `Atomex.Types.Person` for accepted attributes
"""
@spec author(Atomex.Feed.t, binary(), list()) :: Atomex.Feed.t
def author(feed, name, attributes \\ []),
do: add_field(feed, Person.new(:author, name, attributes))

@doc """
Add a link to the feed. See `Atomex.Types.Link` for accepted attributes
"""
@spec link(Atomex.Feed.t, binary(), list()) :: Atomex.Feed.t
def link(feed, href, attributes \\ []),
do: add_field(feed, Link.new(href, attributes))

@doc """
Add given entries to the feed
"""
@spec entries(Atomex.Feed.t, list(Atomex.Entry.t)) :: Atomex.Feed.t
def entries(feed, entries),
do: feed ++ entries

Expand Down

0 comments on commit 5f0062a

Please sign in to comment.