BartOtten

BartOtten

Warning: documentation references type "Phoenix.Router.Route.t()" but the module Phoenix.Router.Route is hidden

Problem

In one of my libs I add type information such as @type routes :: [Phoenix.Router.Route.t()]

This causes mix docs to throw warnings as the module (not the type) is hidden via @moduledoc false

warning: documentation references type "Phoenix.Router.Route.t()" but the module Phoenix.Router.Route is hidden
    │
 17 │   @type routes :: [Phoenix.Router.Route.t()]
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/routex/extension.ex:17: Routex.Extension (module)

Partial solution

In a related Github issue the users works around the module being hidden, by setting skip_undefined_reference_warnings_on. So I applied the same solution.

skip_undefined_reference_warnings_on: ["Routex.Extension","Routex.Processing", "Routex.Route"]

Now, the warnings are gone.

Remaining problem

With the workaround in place, I can add undefined references in 3 modules without being warned.

Question

Who has an idea how to solve this issue?

Solution #1: add a types.ex as a shim so you only need to exclude the shim module.
Solution #2: …?

Most Liked

LostKobrakai

LostKobrakai

You cannot just rely on defp/@typep for project level privacy. They only help with the module level. The convention of using @moduledoc false has been used for a long time in elixir itself and many 3rd party projects to define what is meant to be the public api or not.

LostKobrakai

LostKobrakai

How are you getting access to private structs? Why do you need to interact with them? Generally the solution would be to not depend on things you’re not expected to depend on.

LostKobrakai

LostKobrakai

@moduledoc false denotes the whole module as private to the library – hence the ex_doc warning.

BartOtten

BartOtten

Nope, this is pre-1.18 behavior. I ignored the warnings for a long time as I was aware they were only emitted by ExDocs. Dialyzer uses the type information without issues afaik. After all, types are mainly used for automated checks not as documentation for humans.

So to summarize:

  • ExDocs warns because it does not want to link to an undocumented type / non-existing page. (works)
  • Not linking can be done with :skip_code_autolink_to (works)
  • Referencing in docs (@doc or .md) should cause a warning (works)
  • Referencing an @type in @type should just work* (fails, causes warning in ExDoc)

Any objections to this summary / opinion? :slight_smile:

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

We're in Beta

About us Mission Statement