ex_doc icon indicating copy to clipboard operation
ex_doc copied to clipboard

Do not link to undocumented types

Open ericmj opened this issue 12 years ago • 3 comments

Here: http://elixir-lang.org/docs/master/Version.html we link to the types Version.Schema.t and Version.Requirement.t. The types are not documented which is creating 404 links.

We should make sure we are not creating 404 links and we could warn that we are referencing a type that is not documented.

ericmj avatar Dec 27 '13 14:12 ericmj

It looks like this is a problem with the autolinker, while it does check whether modules and functions exist in the current project it doesn't do so for types.

pminten avatar Dec 28 '13 10:12 pminten

I spent a little bit of time looking at this and here's what I found. Suspect you guys already knew most of it, but I'm going to say it out loud for my understanding.

For the Version.Schema.t example, Version.Schema is a defrecord inside Version which does not have any documentation. ExDoc.Retriever.verify_module/2 removes these records from the list of modules to build documentation pages for. There is a comment calling out this fact in the code. Something about waiting for maps...

When ExDoc.HTMLFormatter.Autolink.typespec/3 runs, it calls ExDoc.HTMLFormatter.Autolink.get_source/2 which doesn't find Version.Schema in the local aliases list, but does find the beam file in the elixir lib path. At that point it constructs a link to where the doc page would be (had it not been stripped by the Retriever). You need this elixir lib path check in general to catch other generic types (like String).

Based on this, I don't see an easy way to catch this case. One option would be to allow doc pages to be created for these records. Or find some way to check __info__ and figure out it's not something we should be linking to.

jwarwick avatar Dec 31 '13 04:12 jwarwick

Closing in favor of #192.

josevalim avatar Aug 07 '15 10:08 josevalim