diff --git a/lib/ex_doc/formatter/epub.ex b/lib/ex_doc/formatter/epub.ex index b45d71aaf..7e3e5def9 100644 --- a/lib/ex_doc/formatter/epub.ex +++ b/lib/ex_doc/formatter/epub.ex @@ -68,8 +68,9 @@ defmodule ExDoc.Formatter.EPUB do defp generate_content(config, nodes, uuid, datetime, static_files) do static_files = - Enum.filter(static_files, fn(name) -> - String.contains?(name, "OEBPS") and config.output |> Path.join(name) |> File.regular?() + static_files + |> Enum.filter(fn(name) -> + String.contains?(name, "OEBPS") and config.output |> Path.join(name) |> File.regular?() end) |> Enum.map(&Path.relative_to(&1, "OEBPS")) @@ -121,7 +122,7 @@ defmodule ExDoc.Formatter.EPUB do ## Helpers - defp default_assets() do + defp default_assets do [{Assets.dist(), "OEBPS/dist"}, {Assets.metainfo(), "META-INF"}] end diff --git a/lib/ex_doc/formatter/epub/assets.ex b/lib/ex_doc/formatter/epub/assets.ex index 0629086f9..a82333d1c 100644 --- a/lib/ex_doc/formatter/epub/assets.ex +++ b/lib/ex_doc/formatter/epub/assets.ex @@ -1,4 +1,6 @@ defmodule ExDoc.Formatter.EPUB.Assets do + @moduledoc false + @assets_dir Application.app_dir(:ex_doc, "priv/ex_doc/formatter/epub/assets") defmacrop embed_dir(dir) do @@ -8,11 +10,11 @@ defmodule ExDoc.Formatter.EPUB.Assets do |> Enum.map(&{Path.basename(&1), File.read!(&1)}) end - def dist() do + def dist do embed_dir("dist") end - def metainfo() do + def metainfo do embed_dir("metainfo") end end diff --git a/lib/ex_doc/formatter/html.ex b/lib/ex_doc/formatter/html.ex index d6114f193..b6c200195 100644 --- a/lib/ex_doc/formatter/html.ex +++ b/lib/ex_doc/formatter/html.ex @@ -151,7 +151,7 @@ defmodule ExDoc.Formatter.HTML do end) end - defp default_assets() do + defp default_assets do [{Assets.dist(), "dist"}, {Assets.fonts(), "fonts"}] end diff --git a/lib/ex_doc/formatter/html/assets.ex b/lib/ex_doc/formatter/html/assets.ex index 33477fd83..b708221d5 100644 --- a/lib/ex_doc/formatter/html/assets.ex +++ b/lib/ex_doc/formatter/html/assets.ex @@ -1,4 +1,6 @@ defmodule ExDoc.Formatter.HTML.Assets do + @moduledoc false + @assets_dir Application.app_dir(:ex_doc, "priv/ex_doc/formatter/html/assets") defmacrop embed_dir(dir) do @@ -8,11 +10,11 @@ defmodule ExDoc.Formatter.HTML.Assets do |> Enum.map(&{Path.basename(&1), File.read!(&1)}) end - def dist() do + def dist do embed_dir("dist") end - def fonts() do + def fonts do embed_dir("fonts") end end diff --git a/lib/ex_doc/formatter/html/autolink.ex b/lib/ex_doc/formatter/html/autolink.ex index 7d122cb30..c8ba7a1ba 100644 --- a/lib/ex_doc/formatter/html/autolink.ex +++ b/lib/ex_doc/formatter/html/autolink.ex @@ -202,7 +202,7 @@ defmodule ExDoc.Formatter.HTML.Autolink do will get translated to the new href of the function. """ def local_doc(bin, locals) when is_binary(bin) do - fun_re = ~r{(([ct]:)?([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-]+)/\d+)} |> Regex.source + fun_re = Regex.source(~r{(([ct]:)?([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-]+)/\d+)}) regex = ~r{(? if match in locals do @@ -258,8 +258,8 @@ defmodule ExDoc.Formatter.HTML.Autolink do will get translated to the new href of the function. """ def elixir_functions(bin, project_funs, extension \\ ".html", lib_dirs \\ elixir_lib_dirs()) when is_binary(bin) do - module_re = ~r{(([A-Z][A-Za-z_\d]+)\.)+} |> Regex.source - fun_re = ~r{([ct]:)?(#{module_re}([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-]+)/\d+)} |> Regex.source + module_re = Regex.source(~r{(([A-Z][A-Za-z_\d]+)\.)+}) + fun_re = Regex.source(~r{([ct]:)?(#{module_re}([a-z_]+[A-Za-z_\d]*[\\?\\!]?|[\{\}=&\\|\\.<>~*^@\\+\\%\\!-]+)/\d+)}) regex = ~r{(? diff --git a/lib/ex_doc/markdown.ex b/lib/ex_doc/markdown.ex index e031d5ffe..62b457868 100644 --- a/lib/ex_doc/markdown.ex +++ b/lib/ex_doc/markdown.ex @@ -47,7 +47,7 @@ defmodule ExDoc.Markdown do bin end - defp get_markdown_processor() do + defp get_markdown_processor do case Application.fetch_env(:ex_doc, @markdown_processor_key) do {:ok, processor} -> processor @@ -58,13 +58,13 @@ defmodule ExDoc.Markdown do end end - defp find_markdown_processor() do + defp find_markdown_processor do Enum.find @markdown_processors, fn module -> Code.ensure_loaded?(module) && module.available? end end - defp raise_no_markdown_processor() do + defp raise_no_markdown_processor do raise """ Could not find a markdown processor to be used by ex_doc. You can either: diff --git a/lib/ex_doc/retriever.ex b/lib/ex_doc/retriever.ex index 631fd54ff..846da747b 100644 --- a/lib/ex_doc/retriever.ex +++ b/lib/ex_doc/retriever.ex @@ -513,7 +513,7 @@ defmodule ExDoc.Retriever do end defp source_path(module, config) do - source = module.__info__(:compile)[:source] |> String.Chars.to_string + source = String.Chars.to_string(module.__info__(:compile)[:source]) if root = config.source_root do Path.relative_to(source, root) diff --git a/lib/mix/tasks/docs.ex b/lib/mix/tasks/docs.ex index b9fd9c79d..4c388e8d9 100644 --- a/lib/mix/tasks/docs.ex +++ b/lib/mix/tasks/docs.ex @@ -213,7 +213,7 @@ defmodule Mix.Tasks.Docs do Keyword.put(options, :deps, deps) end - defp get_deps() do + defp get_deps do for {key, _} <- Mix.Project.deps_paths, _ = Application.load(key), # :ok | {:error, _} vsn = Application.spec(key, :vsn) do diff --git a/test/ex_doc/formatter/epub/templates_test.exs b/test/ex_doc/formatter/epub/templates_test.exs index 87ece4e82..332574e00 100644 --- a/test/ex_doc/formatter/epub/templates_test.exs +++ b/test/ex_doc/formatter/epub/templates_test.exs @@ -62,27 +62,6 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do assert content =~ ~s{example(foo, bar \\\\ Baz)} end - test "module_page outputs the types and function specs" do - content = get_module_page([TypesAndSpecs, TypesAndSpecs.Sub]) - - public_html = - ~S[public(t) :: {t, ] <> - ~s[String.t, ] <> - ~S[TypesAndSpecs.Sub.t, ] <> - ~S[opaque, :ok | :error}] - - ref_html = ~S[ref() :: {:binary.part, public(any)}] - - assert content =~ ~s[public(t)] - refute content =~ ~s[private] - assert content =~ public_html - assert content =~ ref_html - refute content =~ ~s[private\(t\)] - assert content =~ ~s[A public type] - assert content =~ ~s[add(integer, opaque) :: integer] - refute content =~ ~s[minus(integer, integer) :: integer] - end - test "module_page outputs summaries" do content = get_module_page([CompiledWithDocs]) assert content =~ ~r{
\s*} diff --git a/test/ex_doc/formatter/epub_test.exs b/test/ex_doc/formatter/epub_test.exs index 5762a8ea3..ededf3d12 100644 --- a/test/ex_doc/formatter/epub_test.exs +++ b/test/ex_doc/formatter/epub_test.exs @@ -34,7 +34,7 @@ defmodule ExDoc.Formatter.EPUBTest do defp generate_docs_and_unzip(options) do generate_docs(options) - unzip_dir = "#{doc_config()[:output]}" |> String.to_char_list + unzip_dir = String.to_char_list("#{doc_config()[:output]}") "#{doc_config()[:output]}/#{doc_config()[:project]}-v#{doc_config()[:version]}.epub" |> String.to_char_list |> :zip.unzip([cwd: unzip_dir])