This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,3 @@
(cram
(applies_to :whole_subtree)
(deps %{bin:odoc}))

View file

@ -0,0 +1,3 @@
(library
(public_name odoctest)
(name odoctest))

View file

@ -0,0 +1,3 @@
(** Test linking with stdlib *)
let fprintf = Format.fprintf

View file

@ -0,0 +1,5 @@
Check that a type path referring to Stdlib.Format is resolved:
$ dune build @doc-new
$ grep unresolved _build/default/_doc_new/html/docs/local/odoctest/Odoctest/index.html
[1]

View file

@ -0,0 +1,34 @@
The rules that call odoc know that it is going to read the ODOC_SYNTAX
variable, and can rebuild as needed.
$ cat > dune-project << EOF
> (lang dune 1.1)
> (package (name l))
> EOF
$ cat > dune << EOF
> (library
> (public_name l))
> EOF
$ cat > l.ml << EOF
> module type X = sig end
> EOF
$ detect () {
> if grep -q '>sig<' $1 ; then
> echo it is ocaml
> elif grep -q '{ ... }' $1 ; then
> echo it is reason
> else
> echo it is unknown
> fi
> }
$ dune build @doc-new
$ detect _build/default/_doc_new/html/docs/local/l/L/index.html
it is ocaml
$ ODOC_SYNTAX=re dune build @doc-new
$ detect _build/default/_doc_new/html/docs/local/l/L/index.html
it is reason

View file

@ -0,0 +1,35 @@
We create two libraries `l.one` and `l.two` with a conflicting module.
They build fine, are not co-linkable, but documentation should be able to be
built. See #1645.
$ cat > dune-project << EOF
> (lang dune 1.0)
> (package (name l))
> EOF
$ mkdir one
$ cat > one/dune << EOF
> (library
> (name l_one)
> (public_name l.one)
> (wrapped false))
> EOF
$ touch one/module.ml
$ mkdir two
$ cat > two/dune << EOF
> (library
> (name l_two)
> (public_name l.two)
> (wrapped false))
> EOF
$ touch two/module.ml
$ dune build @install
$ dune build @doc-new
File "Module":
Ambiguous lookup. Possible files: Module
Module
File "Module":
Ambiguous lookup. Possible files: Module
Module

View file

@ -0,0 +1,5 @@
(library
(name hello_world)
(public_name hello_world))
(documentation)

View file

@ -0,0 +1,3 @@
$ dune build @doc-new
$ grep Test _build/default/_doc_new/html/docs/local/hello_world/index.html > /dev/null || echo Missing

View file

@ -0,0 +1,2 @@
module Foo = Odoctest2_sublib.A

View file

@ -0,0 +1,4 @@
module Foo : module type of Odoctest2_sublib.A

View file

@ -0,0 +1,4 @@
(library
(public_name odoctest2)
(libraries odoctest2.sublib))

View file

@ -0,0 +1,9 @@
This test checks that compilation dependencies are correct
$ dune build @doc-new
There should be an expansion of `B.Foo` - ie, a directory called `Foo`:
$ ls _build/default/_doc_new/html/docs/local/odoctest2/Odoctest2/B
Foo
index.html

View file

@ -0,0 +1,4 @@
(library
(name odoctest2_sublib)
(public_name odoctest2.sublib))

View file

@ -0,0 +1,5 @@
This test checks that there is no clash when two private libraries have the same name
$ dune build --display short @doc-new 2>&1 | grep docs/test
odoc _doc_new/html/docs/test@38f98c954b37/Test
odoc _doc_new/html/docs/test@38f98c954b37/index.html

View file

@ -0,0 +1,2 @@
(lang dune 1.5)
(name ocaml-labs)

View file

@ -0,0 +1,4 @@
{0 Big title}
Let's test a link to {{!page-otherpage}Other page} and see if it works.

View file

@ -0,0 +1,4 @@
{0 The other page}
This is the other page. Congratulations!

View file

@ -0,0 +1,9 @@
Make sure that links between mld files are resolved even when there is
no library associated with the project
This test case is based on code provided by @vphantom, ocaml/dune#2007
$ dune build @doc-new
$ grep -r xref-unresolved _build/default/_doc_new/html/docs/local/odoc_page_link_bug/index.html
[1]

View file

@ -0,0 +1,27 @@
(library
(name foo)
(modules foo foo2 foo3)
(wrapped false)
(private_modules foo3)
(public_name foo))
(library
(name bar)
(public_name bar)
(modules bar))
(library
(name foo_byte)
(modules foo_byte)
(modes byte)
(public_name foo.byte))
(alias
(name foo-mld)
(deps _doc_new/index/local/foo/foo.mld)
(action (echo "%{read:_doc_new/index/local/foo/foo.mld}")))
(alias
(name bar-mld)
(deps _doc_new/index/local/bar/bar.mld)
(action (echo "%{read:_doc_new/index/local/bar/bar.mld}")))

View file

@ -0,0 +1,32 @@
This test generates documentation using odoc for a library:
$ dune build @doc-new
This test if `.odocl` files are generated
$ find _build/default/_doc_new/odoc/local -name '*.odocl' | sort -n
_build/default/_doc_new/odoc/local/bar/bar.odocl
_build/default/_doc_new/odoc/local/foo/byte/foo_byte.odocl
_build/default/_doc_new/odoc/local/foo/foo.odocl
_build/default/_doc_new/odoc/local/foo/foo2.odocl
$ ls _build/default/_doc_new/html/docs/local/
bar
foo
index.html
$ dune build @foo-mld
{0 Package foo}
{1 Sub-indexes}
- {{!page-"byte"}byte}
{1 Library foo}
This library exposes the following toplevel modules:
{!modules:foo foo2}
{1 Library foo.byte}
The entry point of this library is the module:
{!module-Foo_byte}.
$ dune build @bar-mld
{0 Package bar}
{1 Library bar}
The entry point of this library is the module:
{!module-Bar}.

View file

@ -0,0 +1 @@
this is an mld file

View file

@ -0,0 +1,16 @@
Duplicate mld's in different scope
$ dune build @doc-new --display short 2>&1 | grep page
odoc _doc_new/index/page-docs.odoc
odoc _doc_new/index/stdlib/page-stdlib.odoc
odoc _doc_new/index/local/page-local.odoc
odoc _doc_new/index/local/scope2/page-scope2.odoc
odoc _doc_new/index/local/scope1/page-scope1.odoc
odoc _doc_new/odoc/local/scope2/page-foo.odoc
odoc _doc_new/odoc/local/scope1/page-foo.odoc
odoc _doc_new/index/stdlib/page-stdlib.odocl
odoc _doc_new/index/local/page-local.odocl
odoc _doc_new/index/page-docs.odocl
odoc _doc_new/index/local/scope2/page-scope2.odocl
odoc _doc_new/odoc/local/scope2/page-foo.odocl
odoc _doc_new/index/local/scope1/page-scope1.odocl
odoc _doc_new/odoc/local/scope1/page-foo.odocl

View file

@ -0,0 +1,5 @@
(library
(name scope1)
(public_name scope1))
(documentation)

View file

@ -0,0 +1,5 @@
(library
(name scope2)
(public_name scope2))
(documentation)

View file

@ -0,0 +1,5 @@
(library
(name root_lib1)
(public_name root.lib1))
(documentation)

View file

@ -0,0 +1,5 @@
(library
(name root_lib2)
(public_name root.lib2))
(documentation)

View file

@ -0,0 +1,6 @@
Duplicate mld's in the same scope
$ dune build @doc-new
Error: Package root has two mld's with the same basename
_build/default/lib1/test.mld, _build/default/lib2/test.mld
-> required by alias doc-new
[1]

View file

@ -0,0 +1,2 @@
(library
(public_name foo))

View file

@ -0,0 +1,18 @@
This test generates documentation for non-hidden modules only for a library:
$ dune build @doc-new
Hidden modules should be compiled
$ find _build/default/_doc_new/odoc/local/foo -name '*.odoc' | sort -n
_build/default/_doc_new/odoc/local/foo/foo.odoc
_build/default/_doc_new/odoc/local/foo/foo__.odoc
_build/default/_doc_new/odoc/local/foo/foo__Bar.odoc
Hidden modules should not be linked
$ find _build/default/_doc_new/odoc/local/foo -name '*.odocl' | sort -n
_build/default/_doc_new/odoc/local/foo/foo.odocl
We don't expect html for hidden modules
$ find _build/default/_doc_new/html/docs/local/foo -name '*.html' | sort -n
_build/default/_doc_new/html/docs/local/foo/Foo/index.html
_build/default/_doc_new/html/docs/local/foo/index.html

View file

@ -0,0 +1 @@
module type S = module type of B.A

View file

@ -0,0 +1,4 @@
(library
(public_name odoctest3)
(libraries odoctest3.sublib2))

View file

@ -0,0 +1,9 @@
This test checks that compilation dependencies are correct
$ dune build @doc-new
There should be an expansion of S:
$ ls _build/default/_doc_new/html/docs/local/odoctest3/Odoctest3/C/
index.html
module-type-S

View file

@ -0,0 +1,4 @@
(library
(name sublib1)
(wrapped false)
(public_name odoctest3.sublib1))

View file

@ -0,0 +1,6 @@
(library
(name sublib2)
(wrapped false)
(public_name odoctest3.sublib2)
(libraries sublib1))

View file

@ -0,0 +1,4 @@
(env
(dev
(odoc
(warnings fatal))))

View file

@ -0,0 +1,2 @@
(documentation
(package foo_doc))

View file

@ -0,0 +1,4 @@
(library
(name foo)
(public_name foo_lib)
(modules_without_implementation foo))

View file

@ -0,0 +1,2 @@
(** [t *)
type t = int

View file

@ -0,0 +1,38 @@
$ export BUILD_PATH_PREFIX_MAP=odoc=`command -v odoc`
As configured in the `dune` file at the root, this should be an error:
$ dune build --only-packages=foo_doc @doc-new
File "../../../../foo_doc/foo.mld", line 4, characters 0-0:
Error: End of text is not allowed in '[...]' (code).
ERROR: Warnings have been generated.
[1]
Same for documentation in mli files:
$ dune build --only-packages=foo_lib @doc-new
File "foo_lib/foo.mli", line 1, characters 7-7:
Error: End of text is not allowed in '[...]' (code).
ERROR: Warnings have been generated.
[1]
These packages are in a nested env, the option is disabled, should success with warning printed:
$ dune build --only-packages=bar_doc,bar_lib @doc-new
File "../../../../sub_env/bar_doc/bar.mld", line 4, characters 0-0:
Error: End of text is not allowed in '[...]' (code).
ERROR: Warnings have been generated.
File "sub_env/bar_lib/bar.mli", line 1, characters 7-7:
Error: End of text is not allowed in '[...]' (code).
ERROR: Warnings have been generated.
[1]
In release mode, no error:
$ dune build -p foo_doc,foo_lib @doc-new
(cd _build/default/_doc_new/odoc/local/foo_lib && odoc compile -I . -I ../../stdlib -o foo.odoc ../../../../foo_lib/.foo.objs/byte/foo.cmti -I ../../../index/local/foo_lib --parent 'page-"foo_lib"')
File "foo_lib/foo.mli", line 1, characters 7-7:
Warning: End of text is not allowed in '[...]' (code).
(cd _build/default/_doc_new/odoc/local/foo_doc && odoc compile -o page-foo.odoc ../../../../foo_doc/foo.mld -I ../../../index/local/foo_doc --parent 'page-"foo_doc"')
File "../../../../foo_doc/foo.mld", line 4, characters 0-0:
Warning: End of text is not allowed in '[...]' (code).

View file

@ -0,0 +1,2 @@
(documentation
(package bar_doc))

View file

@ -0,0 +1,4 @@
(library
(name bar)
(public_name bar_lib)
(modules_without_implementation bar))

View file

@ -0,0 +1,4 @@
(env
(dev
(odoc
(warnings nonfatal))))