Skip to content

Commit 6da2232

Browse files
authored
Edoc still includes private functions so need to remove them (#1968)
In cf49545 the pruning of edoc function was removed which causes more functions than there should be to be part of the generated docs. This commit restores the old behaviour and adds a testcase.
1 parent 36adbeb commit 6da2232

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: lib/ex_doc/language/erlang.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ defmodule ExDoc.Language.Erlang do
6262
def function_data(entry, module_data) do
6363
{{kind, name, arity}, _anno, _signature, doc_content, metadata} = entry
6464

65-
if kind == :function and doc_content != :hidden do
65+
# Edoc on Erlang/OTP24.1+ includes private functions in
66+
# the chunk, so we manually yank them out.
67+
if kind == :function and doc_content != :hidden and
68+
function_exported?(module_data.module, name, arity) do
6669
function_data(name, arity, doc_content, module_data, metadata)
6770
else
6871
:skip

Diff for: test/ex_doc/retriever/erlang_test.exs

+8-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ defmodule ExDoc.Retriever.ErlangTest do
376376
%% @doc
377377
%% mod docs.
378378
-module(mod).
379-
-export([function1/0, function2/0]).
379+
-export([function1/0, function2/0, hidden_function/0]).
380380
381381
%% @doc
382382
%% function1/0 docs.
@@ -386,6 +386,13 @@ defmodule ExDoc.Retriever.ErlangTest do
386386
%% @doc
387387
%% function2/0 docs.
388388
function2() -> ok.
389+
390+
%% @doc hidden function docs.
391+
%% @private
392+
hidden_function() -> local_function().
393+
394+
%% @doc hidden function docs.
395+
local_function() -> local_function().
389396
""")
390397

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

0 commit comments

Comments
 (0)