Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
$ odoc link test2.odoc
$ odoc html-generate test.odocl -o html --indent

$ odoc html-targets test.odocl -o html --indent
html/test/Test/index.html

This should have the breadcrumbs in it as a nav with id 'odoc-nav'. Let's also
check it's got the expected content by looking for 'type-t'

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

$ odoc html-generate test.odocl -o html --as-json --indent
$ grep type-t html/test/Test/index.html.json
$ cat html/test/Test/index.html.json
{"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>"}

$ odoc html-targets test.odocl -o html --as-json --indent
Expand Down
1 change: 1 addition & 0 deletions test/integration/json_expansion.t/a.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module B = struct end
2 changes: 2 additions & 0 deletions test/integration/json_expansion.t/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module A = Main__A
(** @canonical Main.A *)
27 changes: 27 additions & 0 deletions test/integration/json_expansion.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Test the JSON output in the presence of expanded modules.

$ ocamlc -c -o main__A.cmo a.ml -bin-annot -I .
$ ocamlc -c main.ml -bin-annot -I .
$ odoc compile -I . main__A.cmt
$ odoc compile -I . main.cmt
$ odoc link -I . main.odoc

$ odoc html-targets -o html main.odocl
html/Main/index.html
html/Main/A/index.html
html/Main/A/B/index.html
$ odoc html-targets --as-json -o html main.odocl
html/Main/index.html.json
html/Main/A/index.html.json
html/Main/A/B/index.html.json

$ odoc html-generate --as-json -o html main.odocl

$ cat html/Main/index.html.json
{"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>"}

$ cat html/Main/A/index.html.json
{"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>"}

$ cat html/Main/A/B/index.html.json
{"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":""}