Skip to content

Commit

Permalink
Add a test case for preable of hidden modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow committed Feb 24, 2021
1 parent 203847d commit 113d006
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/xref2/module_preamble.t/a.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module B = A__b
(** @canonical B *)
4 changes: 4 additions & 0 deletions test/xref2/module_preamble.t/a.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(** Module A. *)

module B = A__b
(** @canonical B *)
1 change: 1 addition & 0 deletions test/xref2/module_preamble.t/b.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type t
11 changes: 11 additions & 0 deletions test/xref2/module_preamble.t/b.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(**************************************************************************)
(* *)
(* An header *)
(* *)
(**************************************************************************)

(** Module B.
Some documentation. *)

type t
297 changes: 297 additions & 0 deletions test/xref2/module_preamble.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
$ ocamlc -bin-annot -o a__b.cmi -c b.mli
$ ocamlc -bin-annot -o a__b.cmo -c b.ml
$ ocamlc -bin-annot -o a.cmi -c a.mli
$ ocamlc -bin-annot -o a.cmo -c a.ml
$ ocamlc -bin-annot -a -o a.cma a.cmo a__b.cmo

$ odoc compile --pkg test -o a__b.odoc -I . a__b.cmti
$ odoc compile --pkg test -o a.odoc -I . a.cmti

$ odoc link -I . a__b.odoc
$ odoc link -I . a.odoc

$ odoc_print a.odocl
{
"id": { "`Root": [ { "`RootPage": "test" }, "A" ] },
"root": "<root>",
"doc": [
[
"a.mli 1:4 1:13",
{
"`Paragraph": [
[ "a.mli 1:4 1:10", { "`Word": "Module" } ],
[ "a.mli 1:10 1:11", "`Space" ],
[ "a.mli 1:11 1:13", { "`Word": "A." } ]
]
}
]
],
"digest": "<digest>",
"imports": [
{ "Resolved": [ "<root>", "A__b" ] },
{ "Unresolved": [ "CamlinternalFormatBasics", { "Some": "<digest>" } ] },
{ "Unresolved": [ "Stdlib", { "Some": "<digest>" } ] }
],
"source": {
"Some": {
"file": "a.mli",
"build_dir": "$TESTCASE_ROOT",
"digest": "<digest>"
}
},
"interface": "true",
"hidden": "false",
"content": {
"Module": {
"items": [
{
"Module": [
"Ordinary",
{
"id": {
"`Module": [
{ "`Root": [ { "`RootPage": "test" }, "A" ] },
"B"
]
},
"doc": [
[
"a.mli 4:4 4:17",
{
"`Tag": {
"`Canonical": [
{ "`Root": "B" },
{ "`Root": [ "B", "`TUnknown" ] }
]
}
}
]
],
"type_": {
"Alias": [
{
"`Resolved": {
"`Hidden": {
"`Identifier": {
"`Root": [ { "`RootPage": "test" }, "A__b" ]
}
}
}
},
{
"Some": {
"Signature": {
"items": [
{
"Comment": {
"`Docs": [
[
"b.mli 7:4 7:13",
{
"`Paragraph": [
[
"b.mli 7:4 7:10",
{ "`Word": "Module" }
],
[ "b.mli 7:10 7:11", "`Space" ],
[
"b.mli 7:11 7:13",
{ "`Word": "B." }
]
]
}
],
[
"b.mli 9:4 9:23",
{
"`Paragraph": [
[
"b.mli 9:4 9:8",
{ "`Word": "Some" }
],
[ "b.mli 9:8 9:9", "`Space" ],
[
"b.mli 9:9 9:23",
{ "`Word": "documentation." }
]
]
}
]
]
}
},
{
"Type": [
"Ordinary",
{
"id": {
"`Type": [
{
"`Module": [
{
"`Root": [
{ "`RootPage": "test" },
"A"
]
},
"B"
]
},
"t"
]
},
"doc": [],
"equation": {
"params": [],
"private_": "false",
"manifest": "None",
"constraints": []
},
"representation": "None"
}
]
}
],
"compiled": "true"
}
}
}
]
},
"canonical": {
"Some": [
{ "`Root": "B" },
{ "`Root": [ "B", "`TUnknown" ] }
]
},
"hidden": "false"
}
]
}
],
"compiled": "true"
}
},
"expansion": "None"
}

$ odoc_print a__b.odocl
{
"id": { "`Root": [ { "`RootPage": "test" }, "A__b" ] },
"root": "<root>",
"doc": [
[
"b.mli 7:4 7:13",
{
"`Paragraph": [
[ "b.mli 7:4 7:10", { "`Word": "Module" } ],
[ "b.mli 7:10 7:11", "`Space" ],
[ "b.mli 7:11 7:13", { "`Word": "B." } ]
]
}
],
[
"b.mli 9:4 9:23",
{
"`Paragraph": [
[ "b.mli 9:4 9:8", { "`Word": "Some" } ],
[ "b.mli 9:8 9:9", "`Space" ],
[ "b.mli 9:9 9:23", { "`Word": "documentation." } ]
]
}
]
],
"digest": "<digest>",
"imports": [
{ "Unresolved": [ "CamlinternalFormatBasics", { "Some": "<digest>" } ] },
{ "Unresolved": [ "Stdlib", { "Some": "<digest>" } ] }
],
"source": {
"Some": {
"file": "b.mli",
"build_dir": "$TESTCASE_ROOT",
"digest": "<digest>"
}
},
"interface": "true",
"hidden": "true",
"content": { "Module": { "items": [], "compiled": "false" } },
"expansion": "None"
}

$ odoc html-generate --indent -o html a.odocl
$ odoc html-generate --indent -o html a__b.odocl

$ cat html/test/A/index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>A (test.A)</title>
<link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/>
<meta name="generator" content="odoc %%VERSION%%"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<script src="../../highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="odoc">
<nav class="odoc-nav"><a href="../index.html">Up</a> –
<a href="../index.html">test</a> &#x00BB; A
</nav>
<header class="odoc-preamble"><h1>Module <code>A</code></h1>
<p>Module A.</p>
</header>
<div class="odoc-content">
<div class="spec module" id="module-B" class="anchored">
<a href="#module-B" class="anchor"></a>
<code><span class="keyword">module</span> <a href="B/index.html">B</a>
: <span class="keyword">sig</span> ... <span class="keyword">end</span>
</code>
</div>
</div>
</body>
</html>

$ cat html/test/A/B/index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>B (test.A.B)</title>
<link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/>
<meta name="generator" content="odoc %%VERSION%%"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<script src="../../../highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="odoc">
<nav class="odoc-nav"><a href="../index.html">Up</a> –
<a href="../../index.html">test</a> &#x00BB; <a href="../index.html">A</a>
&#x00BB; B
</nav>
<header class="odoc-preamble"><h1>Module <code>A.B</code></h1></header>
<div class="odoc-content">
<aside><p>Module B.</p><p>Some documentation.</p></aside>
<div class="spec type" id="type-t" class="anchored">
<a href="#type-t" class="anchor"></a>
<code><span class="keyword">type</span> t</code>
</div>
</div>
</body>
</html>

$ cat html/test/A__b/index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>A__b (test.A__b)</title>
<link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/>
<meta name="generator" content="odoc %%VERSION%%"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<script src="../../highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="odoc">
<nav class="odoc-nav"><a href="../index.html">Up</a> –
<a href="../index.html">test</a> &#x00BB; A__b
</nav>
<header class="odoc-preamble"><h1>Module <code>A__b</code></h1>
<p>Module B.</p><p>Some documentation.</p>
</header><div class="odoc-content"></div>
</body>
</html>

0 comments on commit 113d006

Please # to comment.