Skip to content

Commit 0abfd72

Browse files
eksperimentalwojtekmach
authored andcommitted
Implement suggestions by @wojtekmach
1 parent 326386f commit 0abfd72

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/ex_doc/autolink.ex

+6-5
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,12 @@ defmodule ExDoc.Autolink do
479479
{:type, :hidden} ->
480480
nil
481481

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

486+
_ ->
487+
maybe_warn(ref, config, visibility, %{original_text: original_text})
487488
nil
488489
end
489490
end
@@ -506,7 +507,7 @@ defmodule ExDoc.Autolink do
506507
nil
507508

508509
tool ->
509-
if module == config.current_module do
510+
if same_module? do
510511
fragment(tool, kind, name, arity)
511512
else
512513
app_module_url(tool, module, config) <> fragment(tool, kind, name, arity)

lib/ex_doc/refs.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ defmodule ExDoc.Refs do
123123
if Code.ensure_loaded?(module) do
124124
(to_refs(exports(module), module, :function) ++
125125
to_refs(callbacks(module), module, :callback) ++
126-
to_refs(types(module), module, :type) ++
126+
to_refs(types(module, [:type, :opaque]), module, :type) ++
127127
to_refs(types(module, [:typep]), module, :type, :hidden))
128128
|> Enum.concat([{{:module, module}, :public}])
129129
else
@@ -155,7 +155,7 @@ defmodule ExDoc.Refs do
155155
end
156156
end
157157

158-
defp types(module, kind_list \\ [:type, :opaque]) do
158+
defp types(module, kind_list) do
159159
case Code.Typespec.fetch_types(module) do
160160
{:ok, list} ->
161161
for {kind, {name, _, args}} <- list,

test/mix/tasks/docs_test.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ defmodule Mix.Tasks.DocsTest do
8282
] = run([], app: :ex_doc, docs: [])
8383

8484
assert List.keyfind(deps, :earmark_parser, 0) ==
85-
{:earmark_parser, "https://hexdocs.pm/earmark_parser/#{Application.spec(:earmark_parser, :vsn)}/"}
85+
{:earmark_parser,
86+
"https://hexdocs.pm/earmark_parser/#{Application.spec(:earmark_parser, :vsn)}/"}
8687
end
8788

8889
test "allows custom dependency paths" do

0 commit comments

Comments
 (0)