From d09aac02229783227b424efd9400d544ad662138 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Wed, 28 Jul 2021 14:38:41 +0200 Subject: [PATCH] Skip Erlang modules that have empty docs (#1383) --- lib/ex_doc/language/erlang.ex | 4 ++++ test/ex_doc/retriever/erlang_test.exs | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/ex_doc/language/erlang.ex b/lib/ex_doc/language/erlang.ex index b33bc4636..cc4583d01 100644 --- a/lib/ex_doc/language/erlang.ex +++ b/lib/ex_doc/language/erlang.ex @@ -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) diff --git a/test/ex_doc/retriever/erlang_test.exs b/test/ex_doc/retriever/erlang_test.exs index b9a046df9..d584dc0be 100644 --- a/test/ex_doc/retriever/erlang_test.exs +++ b/test/ex_doc/retriever/erlang_test.exs @@ -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(). @@ -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]).