odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Warn when using links to fragment instead of dedicated reference

Open MisterDA opened this issue 3 years ago • 4 comments

The Lwt documentation has snippets such as:

- {{: #3_Quickstart} Quick start} links these concepts to actual functions
  in Lwt – the most fundamental ones.
  
  ....
  
  {3 Quick start}

or

{{: #VALfoobar}

Sone of the references were correct at some point, but not anymore. Maybe odoc could warn against this pattern and suggest the appropriate {!…} pattern? In the first case, it would require adding a section and using {!section-…}, in the second {!val:foobar}.

It could also warn linking to a section that has no :section defined, if it doesn't do that already.

MisterDA avatar Oct 15 '21 14:10 MisterDA

There's automatically a label for a heading, {!"quick-start"}. The syntax is weird because of the -, which needs to be escaped with quotes.

The {: ...} syntax is for arbitrary urls, I'm not sure it would make sense to interpret it for the purpose of raising warnings.

These anchors wouldn't work with Odoc 1.5.0 either, perhaps Lwt was using ocamldoc ? In this case, the migration might be more involved. There some doc about that here: https://github.com/ocaml/odoc/blob/master/doc/ocamldoc_differences.mld

Julow avatar Oct 15 '21 14:10 Julow

Is there anything actionable in this issue ? If not please close.

dbuenzli avatar Jun 09 '22 11:06 dbuenzli

I see many of these in Opam packages (not just in Lwt) and it's always in the form {{: #VALfoobar}, never {{: index.html#VALfoobar}. I now think we should trigger a warning in this case and suggest the new syntax (when prefix is #VAL and #<digit>). Many of these exist and it's one of the breaking changes between ocamldoc and odoc.

Julow avatar Jun 13 '22 09:06 Julow

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. The main purpose of this is to keep the issue tracker focused to what is actively being worked on, so that the amount and variety of open yet inactive issues does not overwhelm contributors.

An issue closed as stale is not rejected — further discussion is welcome in its closed state, and it can be resurrected at any time. odoc maintainers regularly check issues that were closed as stale in the past, to see if the time is right to reopen and work on them again. PRs addressing issues closed as stale are as welcome as PRs for open issues. They will be given the same review attention, and any other help.

github-actions[bot] avatar Aug 07 '23 17:08 github-actions[bot]