Skip to content

Commit

Permalink
Implement suggestions by @wojtekmach
Browse files Browse the repository at this point in the history
  • Loading branch information
eksperimental authored and wojtekmach committed Oct 6, 2020
1 parent 326386f commit 0abfd72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,12 @@ defmodule ExDoc.Autolink do
{:type, :hidden} ->
nil

_ ->
unless kind == :type and name in [:required, :optional] and arity == 1 do
maybe_warn(ref, config, visibility, %{original_text: original_text})
end
# skip `@type %{required(...), optional(...), ...}`
{:type, _visibility} when name in [:required, :optional] and arity == 1 ->
nil

_ ->
maybe_warn(ref, config, visibility, %{original_text: original_text})
nil
end
end
Expand All @@ -506,7 +507,7 @@ defmodule ExDoc.Autolink do
nil

tool ->
if module == config.current_module do
if same_module? do
fragment(tool, kind, name, arity)
else
app_module_url(tool, module, config) <> fragment(tool, kind, name, arity)
Expand Down
4 changes: 2 additions & 2 deletions lib/ex_doc/refs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ defmodule ExDoc.Refs do
if Code.ensure_loaded?(module) do
(to_refs(exports(module), module, :function) ++
to_refs(callbacks(module), module, :callback) ++
to_refs(types(module), module, :type) ++
to_refs(types(module, [:type, :opaque]), module, :type) ++
to_refs(types(module, [:typep]), module, :type, :hidden))
|> Enum.concat([{{:module, module}, :public}])
else
Expand Down Expand Up @@ -155,7 +155,7 @@ defmodule ExDoc.Refs do
end
end

defp types(module, kind_list \\ [:type, :opaque]) do
defp types(module, kind_list) do
case Code.Typespec.fetch_types(module) do
{:ok, list} ->
for {kind, {name, _, args}} <- list,
Expand Down
3 changes: 2 additions & 1 deletion test/mix/tasks/docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ defmodule Mix.Tasks.DocsTest do
] = run([], app: :ex_doc, docs: [])

assert List.keyfind(deps, :earmark_parser, 0) ==
{:earmark_parser, "https://hexdocs.pm/earmark_parser/#{Application.spec(:earmark_parser, :vsn)}/"}
{:earmark_parser,
"https://hexdocs.pm/earmark_parser/#{Application.spec(:earmark_parser, :vsn)}/"}
end

test "allows custom dependency paths" do
Expand Down

0 comments on commit 0abfd72

Please sign in to comment.