Skip to content

Commit fefb91b

Browse files
committed
Misc doc changes
Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the main reference doc for this Elixir library which leverage on latest features of ExDoc.
1 parent cf5b6da commit fefb91b

33 files changed

+247
-179
lines changed

.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.gitignore

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1-
/ebin
2-
/deps
3-
/doc
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
417
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
520
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
mailman-*.tar
24+
25+
# Temporary files for e.g. tests
26+
/tmp/
27+
28+
# Misc.
29+
/ebin
630
*.swp
731
*.swo
832
*.swn
933
*.swm
10-
/_build

CONTRIBUTORS.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# Contributors
22

3-
Thank you to all of these wonderful individuals who have contributed to Mailman:
3+
Thank you to all of these wonderful individuals who have contributed to
4+
Mailman, sorted in alphabetical order:
45

5-
* Josh Adams (https://github.com/knewter)
6+
* Anthony Graham (https://github.com/trinode)
7+
* Arunvel Sriram (https://github.com/arunvelsriram)
8+
* Benjamin Nørgaard (https://github.com/blacksails)
69
* Dan McClain (https://github.com/danmcclain)
7-
* Holger Amann (https://github.com/hamann)
8-
* Low Kian Seong (https://github.com/lowks)
9-
* Stian Håklev (https://github.com/houshuang)
1010
* Dejan Štrbac (https://github.com/dejanstrbac)
11-
* Benjamin Nørgaard (https://github.com/blacksails)
12-
* JustMikey (https://github.com/JustMikey)
13-
* swerter (https://github.com/swerter)
14-
* Richard Leland (https://github.com/richleland)
15-
* Max Neuvians (https://github.com/maxneuvians)
16-
* Jeff Weiss (https://github.com/jeffweiss)
17-
* Mickaël Rémond (https://github.com/mremond)
18-
* Anthony Graham (https://github.com/trinode)
1911
* Gerry Shaw (https://github.com/gshaw)
20-
* Martin Maillard (https://github.com/martinmaillard)
12+
* Holger Amann (https://github.com/hamann)
13+
* Jeff Weiss (https://github.com/jeffweiss)
14+
* Josh Adams (https://github.com/knewter)
15+
* JustMikey (https://github.com/JustMikey)
16+
* Kamil Ciemniewski (https://github.com/kamilc)
2117
* Keitaroh Kobayashi (https://github.com/keichan34)
22-
* Arunvel Sriram (https://github.com/arunvelsriram)
18+
* Low Kian Seong (https://github.com/lowks)
2319
* Martin Chabot (https://github.com/martinos)
24-
* Mike Martinson (https://github.com/mmartinson)
25-
* Wojciech Stachowski (https://github.com/Antiavanti)
26-
* Uģis Ozols (https://github.com/ugisozols)
20+
* Martin Maillard (https://github.com/martinmaillard)
2721
* Martin Schurig (https://github.com/schurig)
2822
* Mathieu Rhéaume (https://github.com/ddrmanxbxfr)
23+
* Max Neuvians (https://github.com/maxneuvians)
24+
* Mickaël Rémond (https://github.com/mremond)
25+
* Mike Martinson (https://github.com/mmartinson)
26+
* Richard Leland (https://github.com/richleland)
2927
* Sebastian Kosch (https://github.com/skosch)
30-
* Kamil Ciemniewski (https://github.com/kamilc)
28+
* Stian Håklev (https://github.com/houshuang)
29+
* Uģis Ozols (https://github.com/ugisozols)
30+
* Wojciech Stachowski (https://github.com/Antiavanti)
31+
* swerter (https://github.com/swerter)
3132

3233

3334
(Please let us know if you should be included on this list.)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
LICENSE.txt
1+
LICENSE.md

LICENSE.txt renamed to LICENSE.md

File renamed without changes.

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Mailman 👮
22

3-
![Elixir CI](https://github.com/mailman-elixir/mailman/workflows/Elixir%20CI/badge.svg)
4-
[![Docs](https://img.shields.io/badge/api-docs-green.svg?style=flat)](https://hexdocs.pm/mailman)
5-
[![Hex.pm Version](http://img.shields.io/hexpm/v/mailman.svg?style=flat)](https://hex.pm/packages/mailman)
3+
[![Elixir CI](https://github.com/mailman-elixir/mailman/actions/workflows/elixir.yml/badge.svg)](https://github.com/mailman-elixir/mailman/actions/workflows/elixir.yml)
4+
[![Module Version](https://img.shields.io/hexpm/v/mailman.svg)](https://hex.pm/packages/mailman)
5+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/mailman/)
6+
[![Total Download](https://img.shields.io/hexpm/dt/mailman.svg)](https://hex.pm/packages/mailman)
7+
[![License](https://img.shields.io/hexpm/l/mailman.svg)](https://github.com/mailman-elixir/mailman/blob/master/LICENSE)
8+
[![Last Updated](https://img.shields.io/github/last-commit/mailman-elixir/mailman.svg)](https://github.com/mailman-elixir/mailman/commits/master)
69

710
Mailman lets you send email from your Elixir app.
811

@@ -18,8 +21,17 @@ Mailman lets you send email from your Elixir app.
1821

1922
Mailman is a wrapper around the mighty (but rather low-level) [gen_smtp](https://github.com/vagabond/gen_smtp), the popular Erlang SMTP library.
2023

24+
## Which email library should I choose? Mailman vs. Bamboo vs. Swoosh
25+
The Elixir ecosystem now offers a number of email libraries to choose from.
2126

22-
## Simple example
27+
Mailman has been around the longest. As an Elixir wrapper around the battle-tested [gen_smtp](https://github.com/vagabond/gen_smtp) client, it is designed primarily with SMTP power users in mind. If you are interfacing directly with an SMTP relay, Mailman is for you.
28+
29+
If you instead work with a commercial email service like SendGrid or Mailgun, consider libraries like [Bamboo](https://github.com/thoughtbot/bamboo) and [Swoosh](https://github.com/swoosh/swoosh), which come with clients for these services. Note that both of these libraries offer SMTP adapters as well.
30+
31+
32+
## Simple example
33+
34+
Emails are sent using the `Mailman.deliver` function. All you need is the email itself and a `%Mailman.Context{}` configuration struct:
2335

2436
```elixir
2537
context = %Mailman.Context{
@@ -55,3 +67,10 @@ email = %Mailman.Email{
5567

5668
Mailman.deliver(email, context)
5769
```
70+
71+
## Copyright and License
72+
73+
Copyright (c) 2012 Kamil Ciemniewski
74+
75+
Mailman is released under the MIT License. See the [LICENSE.md](./LICENSE.md) file
76+
for further details.

docs/Overview.md

Lines changed: 0 additions & 52 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/mailman.ex

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
defmodule Mailman do
2+
@moduledoc """
3+
Provides functions to send email.
4+
"""
25

36
defprotocol Adapter do
4-
@moduledoc "Protocol for implementing different medium of emails delivery"
7+
@moduledoc """
8+
Protocol for implementing different medium of emails delivery.
9+
"""
510
def deliver(context, email, message)
611
end
712

813
defprotocol Composer do
9-
@moduledoc "Protocol for implementing different template systems for compiling email bodies"
14+
@moduledoc """
15+
Protocol for implementing different template systems for compiling email bodies.
16+
"""
1017
def compile_part(config, mode, email)
1118
end
1219

13-
@doc "Delivers given email to all addresses and returns a list of Tasks"
20+
@doc """
21+
Delivers given email to all addresses and returns a list of Tasks.
22+
"""
1423
def deliver(email, context, :send_cc_and_bcc, extra_headers) do
1524
bcc_list = email.bcc
1625
cleaned_email = %Mailman.Email{email | bcc: []}
@@ -19,12 +28,12 @@ defmodule Mailman do
1928

2029
to_task = [Adapter.deliver(config, email, message)]
2130

22-
cc_tasks = email.cc |> Enum.map(fn(address) ->
31+
cc_tasks = email.cc |> Enum.map(fn(address) ->
2332
cc_envelope = %Mailman.Email{email | to: [address]}
2433
Adapter.deliver(config, cc_envelope, message)
2534
end)
2635

27-
bcc_tasks = bcc_list |> Enum.map(fn(address) ->
36+
bcc_tasks = bcc_list |> Enum.map(fn(address) ->
2837
bcc_envelope = %Mailman.Email{email | to: [address]}
2938
bcc_message = %Mailman.Email{email | bcc: [address]}
3039
message = Mailman.Render.render(bcc_message, context.composer)
@@ -38,7 +47,9 @@ defmodule Mailman do
3847
deliver(email, context, :send_cc_and_bcc, [])
3948
end
4049

41-
@doc "Delivers given email and returns a Task"
50+
@doc """
51+
Delivers given email and returns a Task.
52+
"""
4253
def deliver(email, context, extra_headers) do
4354
message = Mailman.Render.render(email, context.composer, extra_headers)
4455
Adapter.deliver(Mailman.Context.get_config(context), email, message)

lib/mailman/attachment.ex

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
defmodule Mailman.Attachment do
2-
@moduledoc "A struct defining an attachable file. It automatically detect the mime type based on file extension."
2+
@moduledoc """
3+
A struct defining an attachable file. It automatically detect the mime type
4+
based on file extension.
5+
"""
36

47
defstruct file_name: "",
58
mime_type: "",
@@ -718,14 +721,19 @@ defmodule Mailman.Attachment do
718721
end
719722
end
720723

721-
@doc "Get the attachment struct with disposition 'inline'."
724+
@doc """
725+
Get the attachment struct with disposition 'inline'.
726+
"""
722727
@spec inline(String.t(), String.t(), {String.t(), String.t()}) ::
723728
{:ok, t} | {:error, String.t()}
724729
def inline(url_or_file_path, file_name \\ nil, mime_tuple \\ nil) do
725730
create(url_or_file_path, "inline", file_name, mime_tuple)
726731
end
727732

728-
@doc "Get the attachment struct with disposition 'inline'. Throw an error if anything goes wrong."
733+
@doc """
734+
Get the attachment struct with disposition 'inline'. Throw an error if
735+
anything goes wrong.
736+
"""
729737
@spec inline(String.t(), String.t(), {String.t(), String.t()}) :: t
730738
def inline!(url_or_file_path, file_name \\ nil, mime_tuple \\ nil) do
731739
case inline(url_or_file_path, file_name, mime_tuple) do
@@ -734,12 +742,17 @@ defmodule Mailman.Attachment do
734742
end
735743
end
736744

737-
@doc "Get the attachment struct with disposition 'attachment'."
745+
@doc """
746+
Get the attachment struct with disposition 'attachment'.
747+
"""
738748
def attach(url_or_file_path, file_name \\ nil, mime_tuple \\ nil) do
739749
create(url_or_file_path, "attachment", file_name, mime_tuple)
740750
end
741751

742-
@doc "Get the attachment struct with disposition 'attachment'. Throw an error if anything goes wrong."
752+
@doc """
753+
Get the attachment struct with disposition 'attachment'. Throw an error if
754+
anything goes wrong.
755+
"""
743756
def attach!(url_or_file_path, file_name \\ nil, mime_tuple \\ nil) do
744757
case attach(url_or_file_path, file_name, mime_tuple) do
745758
{:ok, attachment} -> attachment

lib/mailman/context.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
defmodule Mailman.Context do
2-
@moduledoc "Defines the configuration for both rendering and sending of messages"
2+
@moduledoc """
3+
Defines the configuration for both rendering and sending of messages.
4+
"""
35

46
defstruct config: nil, composer: %Mailman.EexComposeConfig{}
57

lib/mailman/eex_composer.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
defmodule Mailman.EexComposer do
2-
@moduledoc "Provides functions for rendering from Eex template files"
2+
@moduledoc """
3+
Provides functions for rendering from Eex template files.
4+
"""
35

46
def compile_part(config, :html, %{html: template, data: data}) do
57
if config.html_file do

lib/mailman/eex_composing_config.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
defmodule Mailman.EexComposeConfig do
2-
@moduledoc "Defines the config for the Eex composer"
2+
@moduledoc """
3+
Defines the config for the EEx composer.
4+
"""
35

4-
defstruct root_path: "", assets_path: "",
6+
defstruct root_path: "", assets_path: "",
57
text_file: false, html_file: false,
68
text_file_path: "", html_file_path: ""
79
end

lib/mailman/email.ex

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
defmodule Mailman.Email do
2-
@moduledoc "Struct representing an email message"
2+
@moduledoc """
3+
Struct representing an email message.
4+
"""
35

46
defstruct subject: "",
5-
from: "",
6-
reply_to: "",
7-
to: [],
8-
cc: [],
9-
bcc: [],
10-
attachments: [],
11-
data: %{},
12-
html: "",
13-
text: "",
14-
delivery: nil
7+
from: "",
8+
reply_to: "",
9+
to: [],
10+
cc: [],
11+
bcc: [],
12+
attachments: [],
13+
data: %{},
14+
html: "",
15+
text: "",
16+
delivery: nil
1517

16-
def parse(message) do
17-
Mailman.Parsing.parse message
18-
end
18+
def parse(message) do
19+
Mailman.Parsing.parse(message)
20+
end
1921

20-
def parse!(message) do
21-
Mailman.Parsing.parse! message
22-
end
22+
def parse!(message) do
23+
Mailman.Parsing.parse!(message)
24+
end
2325
end

lib/mailman/external_smtp_adapter.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
defmodule Mailman.ExternalSmtpAdapter do
2-
@moduledoc "Adapter for sending email via external SMTP server"
2+
@moduledoc """
3+
Adapter for sending email via external SMTP server.
4+
"""
35

4-
@doc "Delivers an email based on specified config"
6+
@doc """
7+
Delivers an email based on specified config.
8+
"""
59
def deliver(config, email, message) do
610
relay_config = [
711
relay: config.relay,

0 commit comments

Comments
 (0)