Skip to content

Commit 809c4ca

Browse files
committed
Add a test case for labels references
- The two references in N are wrong, both are pointing to '../index.html#B', should be '#B' and '../M/index.html#B'. - Label defined in top-comment can't be referenced. - Reference paths are correct.
1 parent e5a2c31 commit 809c4ca

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

test/xref2/labels.t/run.t

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
$ compile test.mli
3+
File "test.mli", line 18, characters 6-10:
4+
Reference to 'B' is ambiguous. Please specify its kind: section-B, section-B.
5+
6+
Labels:
7+
Some are not in order because the 'doc' field appears after the rest in the output.
8+
9+
$ odoc_print test.odocl | jq -c '.. | .["`Heading"]? | select(.) | .[1]["`Label"]'
10+
[{"`Root":[{"`RootPage":"test"},"Test"]},"B"]
11+
[{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]},"D"]
12+
[{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]},"B"]
13+
[{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]},"C"]
14+
[{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"N"]},"B"]
15+
[{"`Root":[{"`RootPage":"test"},"Test"]},"A"]
16+
17+
References to the labels:
18+
We expect resolved references and the heading text filled in.
19+
20+
$ odoc_print test.odocl | jq -c '.. | .["`Reference"]? | select(.)'
21+
[{"`Resolved":{"`Identifier":{"`Label":[{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"N"]},"B"]}}},[{"`Word":"An"},"`Space",{"`Word":"other"},"`Space",{"`Word":"conflicting"},"`Space",{"`Word":"label"}]]
22+
[{"`Resolved":{"`Label":[{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]}},"B"]}},[]]
23+
[{"`Resolved":{"`Identifier":{"`Label":[{"`Root":[{"`RootPage":"test"},"Test"]},"A"]}}},[{"`Word":"First"},"`Space",{"`Word":"label"}]]
24+
[{"`Resolved":{"`Identifier":{"`Label":[{"`Root":[{"`RootPage":"test"},"Test"]},"B"]}}},[{"`Word":"Floating"},"`Space",{"`Word":"label"}]]
25+
[{"`Dot":[{"`Root":["M","`TUnknown"]},"C"]},[]]
26+
[{"`Resolved":{"`Label":[{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]}},"D"]}},[]]
27+
[{"`Resolved":{"`Label":[{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"M"]}},"B"]}},[]]
28+
[{"`Resolved":{"`Label":[{"`Identifier":{"`Module":[{"`Root":[{"`RootPage":"test"},"Test"]},"N"]}},"B"]}},[]]
29+
30+
$ odoc html-generate --indent -o html test.odocl
31+
32+
There are two references in N, one should point to a local label and the other to M.
33+
34+
$ cat html/test/Test/N/index.html
35+
<!DOCTYPE html>
36+
<html xmlns="http://www.w3.org/1999/xhtml">
37+
<head><title>N (test.Test.N)</title>
38+
<link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/>
39+
<meta name="generator" content="odoc %%VERSION%%"/>
40+
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
41+
<script src="../../../highlight.pack.js"></script>
42+
<script>hljs.initHighlightingOnLoad();</script>
43+
</head>
44+
<body class="odoc">
45+
<nav class="odoc-nav"><a href="../index.html">Up</a> –
46+
<a href="../../index.html">test</a> &#x00BB;
47+
<a href="../index.html">Test</a> &#x00BB; N
48+
</nav>
49+
<header class="odoc-preamble">
50+
<h1>Module <code><span>Test.N</span></code></h1>
51+
</header>
52+
<nav class="odoc-toc">
53+
<ul><li><a href="#B">An other conflicting label</a></li></ul>
54+
</nav>
55+
<div class="odoc-content">
56+
<h2 id="B"><a href="#B" class="anchor"></a>An other conflicting label</h2>
57+
<p><a href="../index.html#B">An other conflicting label</a>
58+
<a href="../index.html#B"><code>M:B</code></a>
59+
</p>
60+
</div>
61+
</body>
62+
</html>

test/xref2/labels.t/test.mli

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(** {1:A First label} *)
2+
3+
(** {1:B Floating label} *)
4+
5+
module M : sig
6+
(** {1:C First label of M} *)
7+
8+
(** {1:D Floating label in M} *)
9+
10+
(** {1:B Potentially conflicting label} *)
11+
end
12+
13+
module N : sig
14+
(** *)
15+
16+
(** {1:B An other conflicting label} *)
17+
18+
(** {!B} {!M.B} *)
19+
end
20+
21+
(** References to the labels:
22+
23+
{!A} {!B} {!M.C} {!M.D} {!M.B} {!N.B} *)

0 commit comments

Comments
 (0)