defmodule Foo do
@moduledoc """
`_foo/1`
"""
def _foo(foo) do
foo
end
end
The module docs will link to _foo, but _foo will not show in the generated docs.
A real case happens when you locally link to __using__/1
Don鈥檛 we warn if you link to something without docs?
Here' s a more complete example
defmodule Foo do
@moduledoc """
`_foo/1`, `Foo._foo/1`, `boo/1`, `Foo.boo/1`
"""
def _foo(foo) do
foo
end
end
$ mix docs
Generating docs...
warning: documentation references "Foo.boo/1" but it is undefined or private
lib/foo.ex:2: Foo
View "html" docs at "doc/index.html"
warning: documentation references "Foo.boo/1" but it is undefined or private
lib/foo.ex:2: Foo
View "epub" docs at "doc/buildable.epub"
md5-2430234b4d163f729ddfc06593b6e6e5
Foo
_foo/1, Foo._foo/1, boo/1, Foo.boo/1
As far as I understand, the problem comes from the fact that underscored functions get :public visibility in the ExDoc.Refs cache, but they are ignored when generating docs.
Autolinking relies on the visibility stored in the ExDoc.Refs cache:
This visibility is computed here:
So unless the doc is explicitly hidden we assign :public visibility.
On the other hand, when generating docs there are more specific criteria a function needs to satisfy:
This causes a discrepancy, where some refs are ignored, yet they are marked :public in the cache.
One solution would be to determine the visibility using the same rules as for doc? (in which case it would be better to extract it somewhere).
As far as I understand, the problem comes from the fact that underscored functions get
:publicvisibility in theExDoc.Refscache, but they are ignored when generating docs.Autolinking relies on the
visibilitystored in theExDoc.Refscache:This visibility is computed here:
So unless the doc is explicitly hidden we assign
:publicvisibility.On the other hand, when generating docs there are more specific criteria a function needs to satisfy:
This causes a discrepancy, where some refs are ignored, yet they are marked
:publicin the cache.One solution would be to determine the visibility using the same rules as for
doc?(in which case it would be better to extract it somewhere).
Thank you @jonatanklosko, this is the way to go. I already have a working fix for this. I will upload it soon.