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

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
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement