Skip to content

Commit

Permalink
Skip Erlang modules that have empty docs (#1383)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach authored Jul 28, 2021
1 parent ed109f0 commit d09aac0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/ex_doc/language/erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ defmodule ExDoc.Language.Erlang do
alias ExDoc.{Autolink, Refs}

@impl true
def module_data(_module, {:docs_v1, _, _, _, doc, _, _}, _config) when not is_map(doc) do
:skip
end

def module_data(module, docs_chunk, _config) do
":" <> id = inspect(module)
abst_code = get_abstract_code(module)
Expand Down
16 changes: 13 additions & 3 deletions test/ex_doc/retriever/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ defmodule ExDoc.Retriever.ErlangTest do
assert function2.specs == []
end

@tag :otp23
@tag :otp24
test "module with no docs is skipped", c do
erlc(c, :mod, ~S"""
-module(mod).
""")

[] = Retriever.docs_from_modules([:mod], %ExDoc.Config{})
end

@tag :otp24
test "callbacks", c do
erlc(c, :mod, ~S"""
%% @doc Docs.
-module(mod).
-callback callback1() -> atom().
Expand All @@ -91,15 +102,14 @@ defmodule ExDoc.Retriever.ErlangTest do
assert callback1.id == "c:callback1/0"
assert callback1.type == :callback
assert DocAST.to_string(callback1.doc) == "callback1/0 docs."
assert Path.basename(callback1.source_url) == "mod.erl:3"
# this is an edoc bug, it should be 4
assert callback1.doc_line == 3
assert Path.basename(callback1.source_url) == "mod.erl:4"
assert Erlang.autolink_spec(hd(callback1.specs), []) == "callback1() -> atom()."
end

@tag :otp24
test "types", c do
erlc(c, :mod, ~S"""
%% @doc Docs.
-module(mod).
-export_type([type1/0, opaque1/0]).
Expand Down

0 comments on commit d09aac0

Please sign in to comment.