Skip to content

Commit 503a2e8

Browse files
Julowjonludlam
authored andcommitted
Test --as-json in the presence of subpages
1 parent 799003a commit 503a2e8

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

test/generators/html_opts.t/run.t renamed to test/integration/html_opts.t/run.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
$ odoc link test2.odoc
77
$ odoc html-generate test.odocl -o html --indent
88

9+
$ odoc html-targets test.odocl -o html --indent
10+
html/test/Test/index.html
11+
912
This should have the breadcrumbs in it as a nav with id 'odoc-nav'. Let's also
1013
check it's got the expected content by looking for 'type-t'
1114

@@ -18,7 +21,7 @@ check it's got the expected content by looking for 'type-t'
1821
Generate --as-json embeddable HTML fragment output:
1922

2023
$ odoc html-generate test.odocl -o html --as-json --indent
21-
$ grep type-t html/test/Test/index.html.json
24+
$ cat html/test/Test/index.html.json
2225
{"uses_katex":false,"breadcrumbs":[{"name":"test","href":"../index.html","kind":"page"},{"name":"Test","href":"#","kind":"module"}],"toc":[{"title":"Section 1","href":"#section-1","children":[]},{"title":"Section 2","href":"#section-2","children":[]}],"preamble":"<p>Test</p>","content":"<h2 id=\"section-1\"><a href=\"#section-1\" class=\"anchor\"></a>Section 1</h2><div class=\"odoc-spec\">\u000A <div class=\"spec type anchored\" id=\"type-t\">\u000A <a href=\"#type-t\" class=\"anchor\"></a>\u000A <code><span><span class=\"keyword\">type</span> t</span></code>\u000A </div>\u000A</div><h2 id=\"section-2\"><a href=\"#section-2\" class=\"anchor\"></a>Section 2</h2><div class=\"odoc-spec\">\u000A <div class=\"spec type anchored\" id=\"type-u\">\u000A <a href=\"#type-u\" class=\"anchor\"></a>\u000A <code><span><span class=\"keyword\">type</span> u</span></code>\u000A </div>\u000A</div>"}
2326

2427
$ odoc html-targets test.odocl -o html --as-json --indent
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module B = struct end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module A = Main__A
2+
(** @canonical Main.A *)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Test the JSON output in the presence of expanded modules.
2+
3+
$ ocamlc -c -o main__A.cmo a.ml -bin-annot -I .
4+
$ ocamlc -c main.ml -bin-annot -I .
5+
$ odoc compile -I . main__A.cmt
6+
$ odoc compile -I . main.cmt
7+
$ odoc link -I . main.odoc
8+
9+
$ odoc html-targets -o html main.odocl
10+
html/Main/index.html
11+
html/Main/A/index.html
12+
html/Main/A/B/index.html
13+
$ odoc html-targets --as-json -o html main.odocl
14+
html/Main/index.html.json
15+
html/Main/A/index.html.json
16+
html/Main/A/B/index.html.json
17+
18+
$ odoc html-generate --as-json -o html main.odocl
19+
20+
$ cat html/Main/index.html.json
21+
{"uses_katex":false,"breadcrumbs":[{"name":"Main","href":"#","kind":"module"}],"toc":[],"preamble":"","content":"<div class=\"odoc-spec\"><div class=\"spec module anchored\" id=\"module-A\"><a href=\"#module-A\" class=\"anchor\"></a><code><span><span class=\"keyword\">module</span> <a href=\"A/index.html\">A</a></span><span> : <span class=\"keyword\">sig</span> ... <span class=\"keyword\">end</span></span></code></div></div>"}
22+
23+
$ cat html/Main/A/index.html.json
24+
{"uses_katex":false,"breadcrumbs":[{"name":"Main","href":"../index.html","kind":"module"},{"name":"A","href":"#","kind":"module"}],"toc":[],"preamble":"","content":"<div class=\"odoc-spec\"><div class=\"spec module anchored\" id=\"module-B\"><a href=\"#module-B\" class=\"anchor\"></a><code><span><span class=\"keyword\">module</span> <a href=\"B/index.html\">B</a></span><span> : <span class=\"keyword\">sig</span> ... <span class=\"keyword\">end</span></span></code></div></div>"}
25+
26+
$ cat html/Main/A/B/index.html.json
27+
{"uses_katex":false,"breadcrumbs":[{"name":"Main","href":"../../index.html","kind":"module"},{"name":"A","href":"../index.html","kind":"module"},{"name":"B","href":"#","kind":"module"}],"toc":[],"preamble":"","content":""}

0 commit comments

Comments
 (0)