Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagomajesk committed Apr 10, 2022
1 parent d47c9c1 commit 03c758f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lib/gluttony.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ defmodule Gluttony do
Parsing a xml string from a RSS feed:
{:ok, %{feed: feed, entries: entries}} = Gluttone.parse_string(xml)
{:ok, %{feed: feed, entries: entries}} = Gluttony.parse_string(xml)
When a error happens, the reason is returned:
{:error, reason} = Gluttone.parse_string(xml)
{:error, reason} = Gluttony.parse_string(xml)
You can retrieve a common result interface by specifing the `raw` option as `false`.
This might be usefull to retrieve only relevant and common information, since RSS 2.0 and Atom 1.0 are very different specs:
{:ok, %Gluttony.Feed{}} = Gluttony.parse_string(xml, raw: false)
"""
def parse_string(xml, opts \\ []), do: parse(xml, opts)

Expand Down
4 changes: 3 additions & 1 deletion lib/gluttony/entry.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
defmodule Gluttony.Entry do
@moduledoc false
@moduledoc """
Defines a common entry interface for RSS 2.0 and Atom 1.0 feeds.
"""

@type t :: __MODULE__

Expand Down
4 changes: 3 additions & 1 deletion lib/gluttony/feed.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
defmodule Gluttony.Feed do
@moduledoc false
@moduledoc """
Defines a common channel interface for RSS 2.0 and Atom 1.0 feeds.
"""

@type t :: __MODULE__

Expand Down
5 changes: 5 additions & 0 deletions lib/gluttony/fetchers/favicon.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
defmodule Gluttony.Fetchers.Favicon do
@moduledoc """
Retrieves icons available in the given URL.
Exposes the same functions as `HTTPoison`.
"""

use HTTPoison.Base

def process_response_body(body) do
Expand Down
5 changes: 5 additions & 0 deletions lib/gluttony/fetchers/opengraph.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
defmodule Gluttony.Fetchers.Opengraph do
@moduledoc """
Retrieves opengraph information available in the given URL.
Exposes the same functions as `HTTPoison`.
"""

use HTTPoison.Base

@tags ~w(
Expand Down
12 changes: 9 additions & 3 deletions lib/gluttony/unfurler.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
defmodule Gluttony.Unfurler do
@moduledoc """
Enriches feed data by unfurling available urls.
For feeds, it returns favicons and images available in the URL.
FOr entries, it returns the available opengraph information on the page.
Uses `Gluttony.Fetchers.Favicon` and `Gluttony.Fetchers.Opengraph` internally.
"""

alias Gluttony.{Feed, Entry}

@doc """
Accepts a `Gluttony.Feed` or `Gluttony.Entry` struct and retrieves data from the url.
For `Feed`, it returns favicons and images available in the given URL.
For `Entry`, it returns available opengraph information on the page.
"""
def unfurl(term)

def unfurl(%Feed{url: nil}), do: nil

def unfurl(%Feed{url: url}) do
Expand Down

0 comments on commit 03c758f

Please # to comment.