Skip to content

Commit 512fac1

Browse files
committed
Refactor formatter module name handling and improve markdown template spec attribute formatting
1 parent f71c480 commit 512fac1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/ex_doc.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ defmodule ExDoc do
3535
end
3636

3737
defp find_formatter(name) do
38-
[ExDoc.Formatter, String.upcase(name)]
38+
[ExDoc.Formatter, format_module_name(name)]
3939
|> Module.concat()
4040
|> check_formatter_module(name)
4141
end
4242

43+
defp format_module_name("html"), do: "HTML"
44+
defp format_module_name("epub"), do: "EPUB"
45+
defp format_module_name("markdown"), do: "Markdown"
46+
defp format_module_name(name), do: String.upcase(name)
47+
4348
defp check_formatter_module(modname, argname) do
4449
if Code.ensure_loaded?(modname) do
4550
modname

lib/ex_doc/formatter/markdown/templates.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule ExDoc.Formatter.Markdown.Templates do
2626
def module_type(%{type: type} = _node), do: "(#{type})"
2727

2828
@doc """
29-
Formats the attribute type used to define the spec of the given `node`.
29+
Formats the attribute type used to define the spec of the given `node`.
3030
"""
3131
def format_spec_attribute(module, node) do
3232
module.language.format_spec_attribute(node)
@@ -149,7 +149,7 @@ defmodule ExDoc.Formatter.Markdown.Templates do
149149
@spec synopsis(nil) :: nil
150150
def synopsis(doc) when is_binary(doc) do
151151
case :binary.split(doc, "\n\n") do
152-
[left, _] -> String.trim_trailing(left) |> String.trim_trailing(left, ":") <> "\n\n"
152+
[left, _] -> (String.trim_trailing(left) |> String.trim_trailing(":")) <> "\n\n"
153153
[all] -> all
154154
end
155155
end

0 commit comments

Comments
 (0)