Skip to content

Skip Erlang modules that have empty docs #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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