diff --git a/CHANGES.md b/CHANGES.md index 94ba47a766..ba40295156 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Tags: ### Fixed +- Fix crash on functors returning an alias (@Julow, #1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, #971) - Add references to extension declarations (@gpetiot, @panglesd, #949) diff --git a/src/loader/cmi.ml b/src/loader/cmi.ml index a6e7304105..8429d3bd15 100644 --- a/src/loader/cmi.ml +++ b/src/loader/cmi.ml @@ -938,7 +938,9 @@ let rec read_module_type env parent (mty : Odoc_model.Compat.module_type) = in let res = read_module_type env (Identifier.Mk.result parent) res in Functor( f_parameter, res) - | Mty_alias _ -> assert false + | Mty_alias p -> + let t_desc = ModPath (Env.Path.read_module env p) in + TypeOf { t_desc; t_expansion = None } and read_module_type_declaration env parent id (mtd : Odoc_model.Compat.modtype_declaration) = let open ModuleType in diff --git a/test/generators/cases/functor_ml.ml b/test/generators/cases/functor_ml.ml new file mode 100644 index 0000000000..e88786c084 --- /dev/null +++ b/test/generators/cases/functor_ml.ml @@ -0,0 +1,13 @@ +module Foo (X : sig + val foo : int +end) = + String + +module Bar = struct + type t +end + +module Foo' (X : sig + val foo : int +end) = + Bar diff --git a/test/generators/html/Functor_ml-Bar.html b/test/generators/html/Functor_ml-Bar.html new file mode 100644 index 0000000000..5b63dab79f --- /dev/null +++ b/test/generators/html/Functor_ml-Bar.html @@ -0,0 +1,26 @@ + + + Bar (Functor_ml.Bar) + + + + + + + + +
+

Module Functor_ml.Bar

+
+
+
+
+ + type t +
+
+
+ + diff --git a/test/generators/html/Functor_ml-Foo'-argument-1-X.html b/test/generators/html/Functor_ml-Foo'-argument-1-X.html new file mode 100644 index 0000000000..f9af5bab3f --- /dev/null +++ b/test/generators/html/Functor_ml-Foo'-argument-1-X.html @@ -0,0 +1,27 @@ + + + X (Functor_ml.Foo'.X) + + + + + + + + +
+

Parameter Foo'.X

+
+
+
+
+ + val foo : int +
+
+
+ + diff --git a/test/generators/html/Functor_ml-Foo'.html b/test/generators/html/Functor_ml-Foo'.html new file mode 100644 index 0000000000..4e915b1f54 --- /dev/null +++ b/test/generators/html/Functor_ml-Foo'.html @@ -0,0 +1,47 @@ + + + Foo' (Functor_ml.Foo') + + + + + + + + +
+

Module Functor_ml.Foo'

+
+ +
+

Parameters +

+
+
+ + module + X + : sig ... + end + + +
+
+

Signature

+
+
+ + type t + = Bar.t + +
+
+
+ + diff --git a/test/generators/html/Functor_ml.html b/test/generators/html/Functor_ml.html new file mode 100644 index 0000000000..b66778c155 --- /dev/null +++ b/test/generators/html/Functor_ml.html @@ -0,0 +1,58 @@ + + + Functor_ml (Functor_ml) + + + + + + + +
+

Module Functor_ml

+
+
+
+
+ + module Foo + (X : + sig ... end + ) : module + type of + Stdlib.String + + +
+
+
+
+ + + module + Bar + + : sig ... + end + + +
+
+
+
+ + + module + Foo' + + (X : + sig ... end + ) : sig ... + end + + +
+
+
+ + diff --git a/test/generators/html/functor_ml.targets b/test/generators/html/functor_ml.targets new file mode 100644 index 0000000000..f341e87b1a --- /dev/null +++ b/test/generators/html/functor_ml.targets @@ -0,0 +1,4 @@ +Functor_ml.html +Functor_ml-Bar.html +Functor_ml-Foo'.html +Functor_ml-Foo'-argument-1-X.html diff --git a/test/generators/latex/Functor_ml.Foo'.tex b/test/generators/latex/Functor_ml.Foo'.tex new file mode 100644 index 0000000000..01a894844d --- /dev/null +++ b/test/generators/latex/Functor_ml.Foo'.tex @@ -0,0 +1,9 @@ +\section{Module \ocamlinlinecode{Functor\_\allowbreak{}ml.\allowbreak{}Foo'}}\label{module-Functor_ml-module-Foo'}% +\subsection{Parameters\label{parameters}}% +\label{module-Functor_ml-module-Foo'-argument-1-X}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Foo'-argument-1-X]{\ocamlinlinecode{X}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor_ml-module-Foo'-argument-1-X-val-foo}\ocamlcodefragment{\ocamltag{keyword}{val} foo : int}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\subsection{Signature\label{signature}}% +\label{module-Functor_ml-module-Foo'-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[module-Functor_ml-module-Bar-type-t]{\ocamlinlinecode{Bar.\allowbreak{}t}}}\\ + + diff --git a/test/generators/latex/Functor_ml.tex b/test/generators/latex/Functor_ml.tex new file mode 100644 index 0000000000..963899c9ec --- /dev/null +++ b/test/generators/latex/Functor_ml.tex @@ -0,0 +1,8 @@ +\section{Module \ocamlinlinecode{Functor\_\allowbreak{}ml}}\label{module-Functor_ml}% +\label{module-Functor_ml-module-Foo}\ocamlcodefragment{\ocamltag{keyword}{module} Foo (\hyperref[module-Functor_ml-module-Foo-argument-1-X]{\ocamlinlinecode{X}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \hyperref[xref-unresolved]{\ocamlinlinecode{Stdlib}}.\allowbreak{}String}\\ +\label{module-Functor_ml-module-Bar}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Bar]{\ocamlinlinecode{Bar}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor_ml-module-Bar-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\label{module-Functor_ml-module-Foo'}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor_ml-module-Foo']{\ocamlinlinecode{Foo'}}}\ocamlcodefragment{ (\hyperref[module-Functor_ml-module-Foo'-argument-1-X]{\ocamlinlinecode{X}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ + +\input{Functor_ml.Foo'.tex} diff --git a/test/generators/latex/functor_ml.targets b/test/generators/latex/functor_ml.targets new file mode 100644 index 0000000000..6aaca023b3 --- /dev/null +++ b/test/generators/latex/functor_ml.targets @@ -0,0 +1,2 @@ +Functor_ml.tex +Functor_ml.Foo'.tex diff --git a/test/generators/link.dune.inc b/test/generators/link.dune.inc index 7966602f32..543fb5b6c6 100644 --- a/test/generators/link.dune.inc +++ b/test/generators/link.dune.inc @@ -166,6 +166,21 @@ (action (run odoc link -o %{target} %{dep:functor2.odoc}))) +(rule + (target functor_ml.cmt) + (action + (run ocamlc -c -bin-annot -o %{target} %{dep:cases/functor_ml.ml}))) + +(rule + (target functor_ml.odoc) + (action + (run odoc compile -o %{target} %{dep:functor_ml.cmt}))) + +(rule + (target functor_ml.odocl) + (action + (run odoc link -o %{target} %{dep:functor_ml.odoc}))) + (rule (target include.cmti) (action @@ -1780,6 +1795,121 @@ (action (diff functor2.targets functor2.targets.gen)))) +(subdir + html + (rule + (targets + Functor_ml.html.gen + Functor_ml-Bar.html.gen + Functor_ml-Foo'.html.gen + Functor_ml-Foo'-argument-1-X.html.gen) + (action + (run + odoc + html-generate + --indent + --flat + --extra-suffix + gen + -o + . + %{dep:../functor_ml.odocl}))) + (rule + (alias runtest) + (action + (diff Functor_ml.html Functor_ml.html.gen))) + (rule + (alias runtest) + (action + (diff Functor_ml-Bar.html Functor_ml-Bar.html.gen))) + (rule + (alias runtest) + (action + (diff Functor_ml-Foo'.html Functor_ml-Foo'.html.gen))) + (rule + (alias runtest) + (action + (diff + Functor_ml-Foo'-argument-1-X.html + Functor_ml-Foo'-argument-1-X.html.gen)))) + +(subdir + html + (rule + (action + (with-outputs-to + functor_ml.targets.gen + (run odoc html-targets -o . %{dep:../functor_ml.odocl} --flat)))) + (rule + (alias runtest) + (action + (diff functor_ml.targets functor_ml.targets.gen)))) + +(subdir + latex + (rule + (targets Functor_ml.tex.gen Functor_ml.Foo'.tex.gen) + (action + (run + odoc + latex-generate + -o + . + --extra-suffix + gen + %{dep:../functor_ml.odocl}))) + (rule + (alias runtest) + (action + (diff Functor_ml.tex Functor_ml.tex.gen))) + (rule + (alias runtest) + (action + (diff Functor_ml.Foo'.tex Functor_ml.Foo'.tex.gen)))) + +(subdir + latex + (rule + (action + (with-outputs-to + functor_ml.targets.gen + (run odoc latex-targets -o . %{dep:../functor_ml.odocl})))) + (rule + (alias runtest) + (action + (diff functor_ml.targets functor_ml.targets.gen)))) + +(subdir + man + (rule + (targets Functor_ml.3o.gen Functor_ml.Bar.3o.gen Functor_ml.Foo'.3o.gen) + (action + (run odoc man-generate -o . --extra-suffix gen %{dep:../functor_ml.odocl}))) + (rule + (alias runtest) + (action + (diff Functor_ml.3o Functor_ml.3o.gen))) + (rule + (alias runtest) + (action + (diff Functor_ml.Bar.3o Functor_ml.Bar.3o.gen))) + (rule + (alias runtest) + (action + (diff Functor_ml.Foo'.3o Functor_ml.Foo'.3o.gen)))) + +(subdir + man + (rule + (action + (with-outputs-to + functor_ml.targets.gen + (run odoc man-targets -o . %{dep:../functor_ml.odocl})))) + (rule + (alias runtest) + (action + (diff functor_ml.targets functor_ml.targets.gen)))) + (subdir html (rule diff --git a/test/generators/man/Functor_ml.3o b/test/generators/man/Functor_ml.3o new file mode 100644 index 0000000000..f04b7f0b35 --- /dev/null +++ b/test/generators/man/Functor_ml.3o @@ -0,0 +1,18 @@ + +.TH Functor_ml 3 "" "Odoc" "OCaml Library" +.SH Name +Functor_ml +.SH Synopsis +.sp +.in 2 +\fBModule Functor_ml\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR Foo (X : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]module\fR \f[CB]type\fR \f[CB]of\fR Stdlib\.String +.sp +\f[CB]module\fR Bar : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]module\fR Foo' (X : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Functor_ml.Bar.3o b/test/generators/man/Functor_ml.Bar.3o new file mode 100644 index 0000000000..bcad7d7c23 --- /dev/null +++ b/test/generators/man/Functor_ml.Bar.3o @@ -0,0 +1,14 @@ + +.TH Bar 3 "" "Odoc" "OCaml Library" +.SH Name +Functor_ml\.Bar +.SH Synopsis +.sp +.in 2 +\fBModule Functor_ml\.Bar\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]type\fR t diff --git a/test/generators/man/Functor_ml.Foo'.3o b/test/generators/man/Functor_ml.Foo'.3o new file mode 100644 index 0000000000..5869b9acfa --- /dev/null +++ b/test/generators/man/Functor_ml.Foo'.3o @@ -0,0 +1,30 @@ + +.TH Foo' 3 "" "Odoc" "OCaml Library" +.SH Name +Functor_ml\.Foo' +.SH Synopsis +.sp +.in 2 +\fBModule Functor_ml\.Foo'\fR +.in +.sp +.SH Documentation +.sp +.nf +.sp +.in 3 +\fB1 Parameters\fR +.in +.sp +\f[CB]module\fR X : \f[CB]sig\fR +.br +.ti +2 +\f[CB]val\fR foo : int +.br +\f[CB]end\fR +.sp +.in 3 +\fB2 Signature\fR +.in +.sp +\f[CB]type\fR t = Bar\.t diff --git a/test/generators/man/functor_ml.targets b/test/generators/man/functor_ml.targets new file mode 100644 index 0000000000..b30c7ededb --- /dev/null +++ b/test/generators/man/functor_ml.targets @@ -0,0 +1,3 @@ +Functor_ml.3o +Functor_ml.Bar.3o +Functor_ml.Foo'.3o