Skip to content

Commit

Permalink
Add test for warnings if referencing filtered typespec
Browse files Browse the repository at this point in the history
Closes #1764
  • Loading branch information
wojtekmach committed Nov 21, 2023
1 parent 062e181 commit 7fd5238
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ defmodule ExDoc.Language.Elixir do
original_text = call_string <> "()"

if Enum.any?(config.filtered_modules, &(&1.id == module_string)) do
Autolink.warn(config, "Typespec references filtered module: #{all}")
Autolink.warn(config, "typespec references filtered module: #{all}")
end

url =
Expand Down
15 changes: 5 additions & 10 deletions test/ex_doc/language/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,6 @@ defmodule ExDoc.Language.ElixirTest do
~s|<code class="inline">t:InMemory.unknown/0</code>|
end

test "warning if typespec references filtered module" do
ExDoc.Refs.insert([
{{:module, AutolinkTest.Keep}, :public},
{{:function, AutolinkTest.Filtered}, :public},
{{:type, AutolinkTest.Filtered, :type, 0}, :public}
])

# TODO: testing
end

test "warnings" do
ExDoc.Refs.insert([
{{:module, AutolinkTest.Foo}, :public},
Expand Down Expand Up @@ -578,6 +568,11 @@ defmodule ExDoc.Language.ElixirTest do
autolink_spec(quote(do: t() :: String.bad()), opts)
end) =~ ~s|documentation references type "String.bad()"|

assert warn(fn ->
opts = opts ++ [filtered_modules: [%ExDoc.ModuleNode{id: "String"}]]
autolink_spec(quote(do: t() :: String.t()), opts)
end) == "typespec references filtered module: String.t()"

assert warn(fn ->
autolink_spec(
quote do
Expand Down

0 comments on commit 7fd5238

Please sign in to comment.