Skip to content

Incorrect relative link to page with the reference driver #1384

@gadmm

Description

@gadmm

Issue

A relative link

{{!page-index.section-anchor} Relative link with anchor}

works correctly with dune build @doc but not with odoc_driver.

Removing the anchor:

{{!page-index} Relative link}

reveals that the reference driver links to a different html file which is not the relative page and does not correspond to an .mld file (contrary to the documentation).

An absolute link works but then:

  • It no longer works with dune build @doc, so it is impossible to have a link that works with both currently
  • This forces to hardcode the library name all around

MWE

$ cat doc/index.mld 
{0 heading}

Example text

{1:anchor Section}

$ cat doc/other_page.mld 
{0 Other page}

Example text

{{!page-index} Relative link}

{{!page-index.section-anchor} Relative link with anchor}

{{!/link-example/page-index} Absolute link}

{{!/link-example/page-index.section-anchor} Absolute link with anchor}
$ cat doc/dune
(documentation)
$ cat lib/link_example.ml
let x = 1
$ cat lib/link_example.mli
(** Library example *)
val x : int
$ cat lib/dune
(library
 (name link_example)
 (public_name link-example))

Output of the MWE

With odoc_driver:

<p><a href="link-example/index.html" title="index">Relative link</a></p>
<p><span class="xref-unresolved" title="index.anchor">Relative link with anchor</span></p>
<p><a href="index.html" title="index">Absolute link</a></p>
<p><a href="index.html#anchor" title="anchor">Absolute link with anchor</a></p>

Note that link-example/index.html is an auto-generated page entitled “Library link-example” and not the index.mld page.

With dune build @doc:

<p><a href="index.html" title="index">Relative link</a></p>
<p><a href="index.html#anchor" title="anchor">Relative link with anchor</a></p>
<p><span class="xref-unresolved" title="/link-example/index">Absolute link</span></p>
<p><span class="xref-unresolved" title="/link-example/index.anchor">Absolute link with anchor</span></p>

Expected output of the MWE

<p><a href="index.html" title="index">Relative link</a></p>
<p><a href="index.html#anchor" title="anchor">Relative link with anchor</a></p>
<p><a href="index.html" title="index">Absolute link</a></p>
<p><a href="index.html#anchor" title="anchor">Absolute link with anchor</a></p>

Odoc version

3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions