-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change doc examples to doctests to fix inconsistencies
- Loading branch information
1 parent
68f4aa1
commit 66b88c5
Showing
6 changed files
with
142 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,9 +95,6 @@ defmodule Mail do | |
end) | ||
end | ||
|
||
def get_text(%Mail.Message{headers: %{"content-type" => "text/plain" <> _}} = message), | ||
do: message | ||
|
||
def get_text(%Mail.Message{headers: %{"content-type" => ["text/plain" | _]}} = message), | ||
do: message | ||
|
||
|
@@ -261,8 +258,10 @@ defmodule Mail do | |
@doc """ | ||
Add a new `subject` header | ||
Mail.put_subject(%Mail.Message{}, "Welcome to DockYard!") | ||
%Mail.Message{headers: %{subject: "Welcome to DockYard!"}} | ||
## Examples | ||
iex> Mail.put_subject(%Mail.Message{}, "Welcome to DockYard!") | ||
%Mail.Message{headers: %{"subject" => "Welcome to DockYard!"}} | ||
""" | ||
def put_subject(message, subject), | ||
do: Mail.Message.put_header(message, "subject", subject) | ||
|
@@ -279,15 +278,17 @@ defmodule Mail do | |
Recipients can be added as a single string or a list of strings. | ||
The list of recipients will be concated to the previous value. | ||
Mail.put_to(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{to: ["[email protected]"]}} | ||
## Examples | ||
iex> Mail.put_to(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{"to" => ["[email protected]"]}} | ||
Mail.put_to(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{to: ["[email protected]", "[email protected]"]}} | ||
iex> Mail.put_to(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"to" => ["[email protected]", "[email protected]"]}} | ||
Mail.put_to(%Mail.Message{}, "[email protected]") | ||
|> Mail.put_to(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{to: ["[email protected]", "[email protected]", "[email protected]"]}} | ||
iex> Mail.put_to(%Mail.Message{}, "[email protected]") | ||
iex> |> Mail.put_to(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"to" => ["[email protected]", "[email protected]", "[email protected]"]}} | ||
The value of a recipient must conform to either a string value or a tuple with two elements, | ||
otherwise an `ArgumentError` is raised. | ||
|
@@ -319,15 +320,17 @@ defmodule Mail do | |
Recipients can be added as a single string or a list of strings. | ||
The list of recipients will be concated to the previous value. | ||
Mail.put_cc(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{cc: ["[email protected]"]}} | ||
## Examples | ||
Mail.put_cc(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{cc: ["one@example.com", "two@example.com"]}} | ||
iex> Mail.put_cc(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{"cc" => ["[email protected]"]}} | ||
Mail.put_cc(%Mail.Message{}, "[email protected]") | ||
|> Mail.put_cc(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{cc: ["[email protected]", "[email protected]", "[email protected]"]}} | ||
iex> Mail.put_cc(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"cc" => ["[email protected]", "[email protected]"]}} | ||
iex> Mail.put_cc(%Mail.Message{}, "[email protected]") | ||
iex> |> Mail.put_cc(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"cc" => ["[email protected]", "[email protected]", "[email protected]"]}} | ||
The value of a recipient must conform to either a string value or a tuple with two elements, | ||
otherwise an `ArgumentError` is raised. | ||
|
@@ -359,15 +362,17 @@ defmodule Mail do | |
Recipients can be added as a single string or a list of strings. | ||
The list of recipients will be concated to the previous value. | ||
Mail.put_bcc(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{bcc: ["[email protected]"]}} | ||
## Examples | ||
iex> Mail.put_bcc(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{"bcc" => ["[email protected]"]}} | ||
Mail.put_bcc(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{bcc: ["[email protected]", "[email protected]"]}} | ||
iex> Mail.put_bcc(%Mail.Message{}, ["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"bcc" => ["[email protected]", "[email protected]"]}} | ||
Mail.put_bcc(%Mail.Message{}, "[email protected]") | ||
|> Mail.put_bcc(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{bcc: ["[email protected]", "[email protected]", "[email protected]"]}} | ||
iex> Mail.put_bcc(%Mail.Message{}, "[email protected]") | ||
iex> |> Mail.put_bcc(["[email protected]", "[email protected]"]) | ||
%Mail.Message{headers: %{"bcc" => ["[email protected]", "[email protected]", "[email protected]"]}} | ||
The value of a recipient must conform to either a string value or a tuple with two elements, | ||
otherwise an `ArgumentError` is raised. | ||
|
@@ -396,8 +401,10 @@ defmodule Mail do | |
@doc """ | ||
Add a new `from` header | ||
Mail.put_from(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{from: "[email protected]"}} | ||
## Examples | ||
iex> Mail.put_from(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{"from" => "[email protected]"}} | ||
""" | ||
def put_from(message, sender), | ||
do: Mail.Message.put_header(message, "from", sender) | ||
|
@@ -411,8 +418,10 @@ defmodule Mail do | |
@doc """ | ||
Add a new `reply-to` header | ||
Mail.put_reply_to(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{reply_to: "[email protected]"}} | ||
## Examples | ||
iex> Mail.put_reply_to(%Mail.Message{}, "[email protected]") | ||
%Mail.Message{headers: %{"reply-to" => "[email protected]"}} | ||
""" | ||
def put_reply_to(message, reply_address), | ||
do: Mail.Message.put_header(message, "reply-to", reply_address) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.