From 5632450a3522d4370778bfdb49f378fd53a6e49a Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Wed, 10 Jun 2026 15:15:48 +0200 Subject: [PATCH 1/7] Initial code sample of `include functor` Signed-off-by: Marek Kubica --- test/generators/cases/oxcaml.mli | 6 ++ ...aml-Include_functor-Make-argument-1-T.html | 29 ++++++++ .../html/Oxcaml-Include_functor-Make.html | 50 +++++++++++++ .../html/Oxcaml-Include_functor.html | 48 +++++++++++++ test/generators/html/Oxcaml.html | 13 ++++ test/generators/html/oxcaml.targets | 3 + test/generators/latex/Oxcaml.tex | 5 ++ test/generators/link.dune.inc | 72 ++++++++++++++++++- test/generators/man/Oxcaml.3o | 3 +- test/generators/man/Oxcaml.Include_functor.3o | 18 +++++ .../man/Oxcaml.Include_functor.Make.3o | 30 ++++++++ test/generators/man/oxcaml.targets | 2 + ...xcaml-Include_functor-Make-argument-1-T.md | 6 ++ .../markdown/Oxcaml-Include_functor-Make.md | 15 ++++ .../markdown/Oxcaml-Include_functor.md | 12 ++++ test/generators/markdown/Oxcaml.md | 4 ++ test/generators/markdown/oxcaml.targets | 3 + 17 files changed, 315 insertions(+), 4 deletions(-) create mode 100644 test/generators/html/Oxcaml-Include_functor-Make-argument-1-T.html create mode 100644 test/generators/html/Oxcaml-Include_functor-Make.html create mode 100644 test/generators/html/Oxcaml-Include_functor.html create mode 100644 test/generators/man/Oxcaml.Include_functor.3o create mode 100644 test/generators/man/Oxcaml.Include_functor.Make.3o create mode 100644 test/generators/markdown/Oxcaml-Include_functor-Make-argument-1-T.md create mode 100644 test/generators/markdown/Oxcaml-Include_functor-Make.md create mode 100644 test/generators/markdown/Oxcaml-Include_functor.md diff --git a/test/generators/cases/oxcaml.mli b/test/generators/cases/oxcaml.mli index 11db3f653a..d57e065d51 100644 --- a/test/generators/cases/oxcaml.mli +++ b/test/generators/cases/oxcaml.mli @@ -280,3 +280,9 @@ module M3 : sig @@ contended end (** [contended] modality applied to all definitions in the module, except the ones which have already specified this axis. *) + +module Include_functor : sig + module Make (T : sig type t end) : sig type included end + type t + include functor module type of Make +end diff --git a/test/generators/html/Oxcaml-Include_functor-Make-argument-1-T.html b/test/generators/html/Oxcaml-Include_functor-Make-argument-1-T.html new file mode 100644 index 0000000000..4d5cabd316 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor-Make-argument-1-T.html @@ -0,0 +1,29 @@ + + + T (Oxcaml.Include_functor.Make.T) + + + + + + + + +
+

Parameter Make.T

+
+
+
+
+ + type t +
+
+
+ + diff --git a/test/generators/html/Oxcaml-Include_functor-Make.html b/test/generators/html/Oxcaml-Include_functor-Make.html new file mode 100644 index 0000000000..2cc91dce29 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor-Make.html @@ -0,0 +1,50 @@ + + + Make (Oxcaml.Include_functor.Make) + + + + + + + + +
+

Module Include_functor.Make

+
+
+ +
+
+

Parameters +

+
+
+ + module + T + + : sig ... + end + + +
+
+

Signature

+
+
+ + type included +
+
+
+ + diff --git a/test/generators/html/Oxcaml-Include_functor.html b/test/generators/html/Oxcaml-Include_functor.html new file mode 100644 index 0000000000..f964624cb1 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor.html @@ -0,0 +1,48 @@ + + + Include_functor (Oxcaml.Include_functor) + + + + + + + + +
+

Module Oxcaml.Include_functor

+
+
+
+
+ + + module + Make + + (T + : sig ... + end) : sig + ... end + + +
+
+
+
+ + type t +
+
+
+
+ + type included +
+
+
+ + diff --git a/test/generators/html/Oxcaml.html b/test/generators/html/Oxcaml.html index 88dfb52689..13fda6edc8 100644 --- a/test/generators/html/Oxcaml.html +++ b/test/generators/html/Oxcaml.html @@ -1182,6 +1182,19 @@

+
+
+ + + module + Include_functor + + : sig ... + end + + +
+
diff --git a/test/generators/html/oxcaml.targets b/test/generators/html/oxcaml.targets index 77bc5f1da0..6e0ffbac18 100644 --- a/test/generators/html/oxcaml.targets +++ b/test/generators/html/oxcaml.targets @@ -3,3 +3,6 @@ Oxcaml-module-type-S.html Oxcaml-M1.html Oxcaml-M2.html Oxcaml-M3.html +Oxcaml-Include_functor.html +Oxcaml-Include_functor-Make.html +Oxcaml-Include_functor-Make-argument-1-T.html diff --git a/test/generators/latex/Oxcaml.tex b/test/generators/latex/Oxcaml.tex index 86830b7210..ea40a87f68 100644 --- a/test/generators/latex/Oxcaml.tex +++ b/test/generators/latex/Oxcaml.tex @@ -240,5 +240,10 @@ \subsubsection{Modalities on module declarations\label{Oxcaml--modalities-on-mod \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}\ocamlinlinecode{contended} modality applied to all definitions in the module, except the ones which have already specified this axis.\end{ocamlindent}% \medbreak +\label{Oxcaml--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\label{Oxcaml-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ \input{Oxcaml.M1.tex} diff --git a/test/generators/link.dune.inc b/test/generators/link.dune.inc index 5efe5a1677..88db7ceed8 100644 --- a/test/generators/link.dune.inc +++ b/test/generators/link.dune.inc @@ -11951,7 +11951,10 @@ Oxcaml-module-type-S.html.gen Oxcaml-M1.html.gen Oxcaml-M2.html.gen - Oxcaml-M3.html.gen) + Oxcaml-M3.html.gen + Oxcaml-Include_functor.html.gen + Oxcaml-Include_functor-Make.html.gen + Oxcaml-Include_functor-Make-argument-1-T.html.gen) (package odoc) (action (run @@ -11994,6 +11997,28 @@ (package odoc) (action (diff Oxcaml-M3.html Oxcaml-M3.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-Include_functor.html Oxcaml-Include_functor.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor-Make.html + Oxcaml-Include_functor-Make.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor-Make-argument-1-T.html + Oxcaml-Include_functor-Make-argument-1-T.html.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12054,7 +12079,13 @@ (subdir man (rule - (targets Oxcaml.3o.gen Oxcaml.M1.3o.gen Oxcaml.M2.3o.gen Oxcaml.M3.3o.gen) + (targets + Oxcaml.3o.gen + Oxcaml.M1.3o.gen + Oxcaml.M2.3o.gen + Oxcaml.M3.3o.gen + Oxcaml.Include_functor.3o.gen + Oxcaml.Include_functor.Make.3o.gen) (package odoc) (action (run odoc man-generate -o . --extra-suffix gen %{dep:../oxcaml.odocl})) @@ -12082,6 +12113,18 @@ (package odoc) (action (diff Oxcaml.M3.3o Oxcaml.M3.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml.Include_functor.3o Oxcaml.Include_functor.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml.Include_functor.Make.3o Oxcaml.Include_functor.Make.3o.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12109,7 +12152,10 @@ Oxcaml-module-type-S.md.gen Oxcaml-M1.md.gen Oxcaml-M2.md.gen - Oxcaml-M3.md.gen) + Oxcaml-M3.md.gen + Oxcaml-Include_functor.md.gen + Oxcaml-Include_functor-Make.md.gen + Oxcaml-Include_functor-Make-argument-1-T.md.gen) (package odoc) (action (run @@ -12150,6 +12196,26 @@ (package odoc) (action (diff Oxcaml-M3.md Oxcaml-M3.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-Include_functor.md Oxcaml-Include_functor.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-Include_functor-Make.md Oxcaml-Include_functor-Make.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor-Make-argument-1-T.md + Oxcaml-Include_functor-Make-argument-1-T.md.gen)) (enabled_if %{ocaml-config:ox}))) (subdir diff --git a/test/generators/man/Oxcaml.3o b/test/generators/man/Oxcaml.3o index ada6bbb18b..5bc2ed6e14 100644 --- a/test/generators/man/Oxcaml.3o +++ b/test/generators/man/Oxcaml.3o @@ -681,4 +681,5 @@ Module with portable modality\. The modality is applied to all value members of .ti +2 contended modality applied to all definitions in the module, except the ones which have already specified this axis\. .nf - +.sp +\f[CB]module\fR Include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Oxcaml.Include_functor.3o b/test/generators/man/Oxcaml.Include_functor.3o new file mode 100644 index 0000000000..91667a49b7 --- /dev/null +++ b/test/generators/man/Oxcaml.Include_functor.3o @@ -0,0 +1,18 @@ + +.TH Include_functor 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.Include_functor +.SH Synopsis +.sp +.in 2 +\fBModule Oxcaml\.Include_functor\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]type\fR t +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml.Include_functor.Make.3o b/test/generators/man/Oxcaml.Include_functor.Make.3o new file mode 100644 index 0000000000..0a52767dec --- /dev/null +++ b/test/generators/man/Oxcaml.Include_functor.Make.3o @@ -0,0 +1,30 @@ + +.TH Make 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.Include_functor\.Make +.SH Synopsis +.sp +.in 2 +\fBModule Include_functor\.Make\fR +.in +.sp +.SH Documentation +.sp +.nf +.sp +.in 3 +\fB1 Parameters\fR +.in +.sp +\f[CB]module\fR T : \f[CB]sig\fR +.br +.ti +2 +\f[CB]type\fR t +.br +\f[CB]end\fR +.sp +.in 3 +\fB2 Signature\fR +.in +.sp +\f[CB]type\fR included diff --git a/test/generators/man/oxcaml.targets b/test/generators/man/oxcaml.targets index 3d3984495e..47608a9575 100644 --- a/test/generators/man/oxcaml.targets +++ b/test/generators/man/oxcaml.targets @@ -2,3 +2,5 @@ Oxcaml.3o Oxcaml.M1.3o Oxcaml.M2.3o Oxcaml.M3.3o +Oxcaml.Include_functor.3o +Oxcaml.Include_functor.Make.3o diff --git a/test/generators/markdown/Oxcaml-Include_functor-Make-argument-1-T.md b/test/generators/markdown/Oxcaml-Include_functor-Make-argument-1-T.md new file mode 100644 index 0000000000..9459dc695c --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor-Make-argument-1-T.md @@ -0,0 +1,6 @@ + +# Parameter `Make.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-Include_functor-Make.md b/test/generators/markdown/Oxcaml-Include_functor-Make.md new file mode 100644 index 0000000000..717336f028 --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor-Make.md @@ -0,0 +1,15 @@ + +# Module `Include_functor.Make` + + +## Parameters + +```ocaml +module T : sig ... end +``` + +## Signature + +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-Include_functor.md b/test/generators/markdown/Oxcaml-Include_functor.md new file mode 100644 index 0000000000..77b7d949e4 --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor.md @@ -0,0 +1,12 @@ + +# Module `Oxcaml.Include_functor` + +```ocaml +module Make (T : sig ... end) : sig ... end +``` +```ocaml +type t +``` +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml.md b/test/generators/markdown/Oxcaml.md index 20ba08da3f..29d93b8584 100644 --- a/test/generators/markdown/Oxcaml.md +++ b/test/generators/markdown/Oxcaml.md @@ -345,3 +345,7 @@ Module with `portable` modality. The modality is applied to all value members of module M3 : sig ... end ``` `contended` modality applied to all definitions in the module, except the ones which have already specified this axis. + +```ocaml +module Include_functor : sig ... end +``` \ No newline at end of file diff --git a/test/generators/markdown/oxcaml.targets b/test/generators/markdown/oxcaml.targets index 03016b8b2f..101eec5c37 100644 --- a/test/generators/markdown/oxcaml.targets +++ b/test/generators/markdown/oxcaml.targets @@ -3,3 +3,6 @@ Oxcaml-module-type-S.md Oxcaml-M1.md Oxcaml-M2.md Oxcaml-M3.md +Oxcaml-Include_functor.md +Oxcaml-Include_functor-Make.md +Oxcaml-Include_functor-Make-argument-1-T.md From fb3bbb4e43af5e1557efbd6056f92db9bdfe8f10 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Thu, 11 Jun 2026 15:36:36 +0200 Subject: [PATCH 2/7] Add non-include-functor version for comparison Signed-off-by: Marek Kubica --- test/generators/cases/oxcaml.mli | 12 +++ ...-No_include_functor-Make-argument-1-T.html | 29 ++++++ .../html/Oxcaml-No_include_functor-Make.html | 51 ++++++++++ .../html/Oxcaml-No_include_functor-T.html | 29 ++++++ .../html/Oxcaml-No_include_functor.html | 92 +++++++++++++++++++ test/generators/html/Oxcaml.html | 21 +++++ test/generators/html/oxcaml.targets | 4 + test/generators/latex/Oxcaml.tex | 9 ++ test/generators/link.dune.inc | 89 ++++++++++++++++++ test/generators/man/Oxcaml.3o | 6 ++ .../man/Oxcaml.No_include_functor.3o | 20 ++++ .../man/Oxcaml.No_include_functor.Make.3o | 30 ++++++ .../man/Oxcaml.No_include_functor.T.3o | 14 +++ test/generators/man/oxcaml.targets | 3 + ...ml-No_include_functor-Make-argument-1-T.md | 6 ++ .../Oxcaml-No_include_functor-Make.md | 15 +++ .../markdown/Oxcaml-No_include_functor-T.md | 6 ++ .../markdown/Oxcaml-No_include_functor.md | 15 +++ test/generators/markdown/Oxcaml.md | 6 ++ test/generators/markdown/oxcaml.targets | 4 + 20 files changed, 461 insertions(+) create mode 100644 test/generators/html/Oxcaml-No_include_functor-Make-argument-1-T.html create mode 100644 test/generators/html/Oxcaml-No_include_functor-Make.html create mode 100644 test/generators/html/Oxcaml-No_include_functor-T.html create mode 100644 test/generators/html/Oxcaml-No_include_functor.html create mode 100644 test/generators/man/Oxcaml.No_include_functor.3o create mode 100644 test/generators/man/Oxcaml.No_include_functor.Make.3o create mode 100644 test/generators/man/Oxcaml.No_include_functor.T.3o create mode 100644 test/generators/markdown/Oxcaml-No_include_functor-Make-argument-1-T.md create mode 100644 test/generators/markdown/Oxcaml-No_include_functor-Make.md create mode 100644 test/generators/markdown/Oxcaml-No_include_functor-T.md create mode 100644 test/generators/markdown/Oxcaml-No_include_functor.md diff --git a/test/generators/cases/oxcaml.mli b/test/generators/cases/oxcaml.mli index d57e065d51..f2c0ae266a 100644 --- a/test/generators/cases/oxcaml.mli +++ b/test/generators/cases/oxcaml.mli @@ -281,6 +281,18 @@ end (** [contended] modality applied to all definitions in the module, except the ones which have already specified this axis. *) +(** {1 Include functor on signatures} *) + +module No_include_functor : sig + module Make (T : sig type t end) : sig type included end + module T : sig + type t + end + + include module type of T + include module type of Make(T) +end + module Include_functor : sig module Make (T : sig type t end) : sig type included end type t diff --git a/test/generators/html/Oxcaml-No_include_functor-Make-argument-1-T.html b/test/generators/html/Oxcaml-No_include_functor-Make-argument-1-T.html new file mode 100644 index 0000000000..e0f179c914 --- /dev/null +++ b/test/generators/html/Oxcaml-No_include_functor-Make-argument-1-T.html @@ -0,0 +1,29 @@ + + + T (Oxcaml.No_include_functor.Make.T) + + + + + + + + +
+

Parameter Make.T

+
+
+
+
+ + type t +
+
+
+ + diff --git a/test/generators/html/Oxcaml-No_include_functor-Make.html b/test/generators/html/Oxcaml-No_include_functor-Make.html new file mode 100644 index 0000000000..aff06ab0bd --- /dev/null +++ b/test/generators/html/Oxcaml-No_include_functor-Make.html @@ -0,0 +1,51 @@ + + + Make (Oxcaml.No_include_functor.Make) + + + + + + + + +
+

Module No_include_functor.Make

+
+
+ +
+
+

Parameters +

+
+
+ + module + T + + : sig ... + end + + +
+
+

Signature

+
+
+ + type included +
+
+
+ + diff --git a/test/generators/html/Oxcaml-No_include_functor-T.html b/test/generators/html/Oxcaml-No_include_functor-T.html new file mode 100644 index 0000000000..f7336627ac --- /dev/null +++ b/test/generators/html/Oxcaml-No_include_functor-T.html @@ -0,0 +1,29 @@ + + + T (Oxcaml.No_include_functor.T) + + + + + + + + +
+

Module No_include_functor.T

+
+
+
+
+ + type t +
+
+
+ + diff --git a/test/generators/html/Oxcaml-No_include_functor.html b/test/generators/html/Oxcaml-No_include_functor.html new file mode 100644 index 0000000000..549444643e --- /dev/null +++ b/test/generators/html/Oxcaml-No_include_functor.html @@ -0,0 +1,92 @@ + + + No_include_functor (Oxcaml.No_include_functor) + + + + + + + + +
+

Module Oxcaml.No_include_functor

+
+
+
+
+ + + module + Make + + ( + T + : sig ... + end) : sig + ... end + + +
+
+
+
+ + + module + T + + : sig ... + end + + +
+
+
+
+ + + include + module type + of + T + + + +
+
+ + type t +
+
+
+
+
+
+ + + include + sig ... end + + + +
+
+ + type included + = + + Make(T).included + + + +
+
+
+
+
+ + diff --git a/test/generators/html/Oxcaml.html b/test/generators/html/Oxcaml.html index 13fda6edc8..f677107377 100644 --- a/test/generators/html/Oxcaml.html +++ b/test/generators/html/Oxcaml.html @@ -72,6 +72,10 @@

Module Oxcaml

+
  • + Include functor on signatures + +
  • @@ -1182,6 +1186,23 @@

    +

    + Include + functor on signatures +

    +
    +
    + + + module + No_include_functor + + : sig ... + end + + +
    +
    diff --git a/test/generators/html/oxcaml.targets b/test/generators/html/oxcaml.targets index 6e0ffbac18..09e7279c6d 100644 --- a/test/generators/html/oxcaml.targets +++ b/test/generators/html/oxcaml.targets @@ -3,6 +3,10 @@ Oxcaml-module-type-S.html Oxcaml-M1.html Oxcaml-M2.html Oxcaml-M3.html +Oxcaml-No_include_functor.html +Oxcaml-No_include_functor-Make.html +Oxcaml-No_include_functor-Make-argument-1-T.html +Oxcaml-No_include_functor-T.html Oxcaml-Include_functor.html Oxcaml-Include_functor-Make.html Oxcaml-Include_functor-Make-argument-1-T.html diff --git a/test/generators/latex/Oxcaml.tex b/test/generators/latex/Oxcaml.tex index ea40a87f68..cc24a98e23 100644 --- a/test/generators/latex/Oxcaml.tex +++ b/test/generators/latex/Oxcaml.tex @@ -240,6 +240,15 @@ \subsubsection{Modalities on module declarations\label{Oxcaml--modalities-on-mod \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}\ocamlinlinecode{contended} modality applied to all definitions in the module, except the ones which have already specified this axis.\end{ocamlindent}% \medbreak +\subsection{Include functor on signatures\label{Oxcaml--include-functor-on-signatures}}% +\label{Oxcaml--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml-No_include_functor--module-T}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor-T]{\ocamlinlinecode{T}}}\label{Oxcaml-No_include_functor-T}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-No_include_functor-T--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamltag{keyword}{include} \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \hyperref[Oxcaml-No_include_functor-T]{\ocamlinlinecode{T}}\label{Oxcaml-No_include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\ocamltag{keyword}{include} \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}\label{Oxcaml-No_include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included = \hyperref[Oxcaml-No_include_functor-Make--type-included]{\ocamlinlinecode{Make(T).\allowbreak{}included}}}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{Oxcaml--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ \label{Oxcaml-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ \label{Oxcaml-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ diff --git a/test/generators/link.dune.inc b/test/generators/link.dune.inc index 88db7ceed8..ff3418e7d8 100644 --- a/test/generators/link.dune.inc +++ b/test/generators/link.dune.inc @@ -11952,6 +11952,10 @@ Oxcaml-M1.html.gen Oxcaml-M2.html.gen Oxcaml-M3.html.gen + Oxcaml-No_include_functor.html.gen + Oxcaml-No_include_functor-Make.html.gen + Oxcaml-No_include_functor-Make-argument-1-T.html.gen + Oxcaml-No_include_functor-T.html.gen Oxcaml-Include_functor.html.gen Oxcaml-Include_functor-Make.html.gen Oxcaml-Include_functor-Make-argument-1-T.html.gen) @@ -11998,6 +12002,36 @@ (action (diff Oxcaml-M3.html Oxcaml-M3.html.gen)) (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-No_include_functor.html Oxcaml-No_include_functor.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-No_include_functor-Make.html + Oxcaml-No_include_functor-Make.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-No_include_functor-Make-argument-1-T.html + Oxcaml-No_include_functor-Make-argument-1-T.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-No_include_functor-T.html + Oxcaml-No_include_functor-T.html.gen)) + (enabled_if %{ocaml-config:ox})) (rule (alias runtest) (package odoc) @@ -12084,6 +12118,9 @@ Oxcaml.M1.3o.gen Oxcaml.M2.3o.gen Oxcaml.M3.3o.gen + Oxcaml.No_include_functor.3o.gen + Oxcaml.No_include_functor.Make.3o.gen + Oxcaml.No_include_functor.T.3o.gen Oxcaml.Include_functor.3o.gen Oxcaml.Include_functor.Make.3o.gen) (package odoc) @@ -12114,6 +12151,26 @@ (action (diff Oxcaml.M3.3o Oxcaml.M3.3o.gen)) (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml.No_include_functor.3o Oxcaml.No_include_functor.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml.No_include_functor.Make.3o + Oxcaml.No_include_functor.Make.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml.No_include_functor.T.3o Oxcaml.No_include_functor.T.3o.gen)) + (enabled_if %{ocaml-config:ox})) (rule (alias runtest) (package odoc) @@ -12153,6 +12210,10 @@ Oxcaml-M1.md.gen Oxcaml-M2.md.gen Oxcaml-M3.md.gen + Oxcaml-No_include_functor.md.gen + Oxcaml-No_include_functor-Make.md.gen + Oxcaml-No_include_functor-Make-argument-1-T.md.gen + Oxcaml-No_include_functor-T.md.gen Oxcaml-Include_functor.md.gen Oxcaml-Include_functor-Make.md.gen Oxcaml-Include_functor-Make-argument-1-T.md.gen) @@ -12197,6 +12258,34 @@ (action (diff Oxcaml-M3.md Oxcaml-M3.md.gen)) (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-No_include_functor.md Oxcaml-No_include_functor.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-No_include_functor-Make.md + Oxcaml-No_include_functor-Make.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-No_include_functor-Make-argument-1-T.md + Oxcaml-No_include_functor-Make-argument-1-T.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml-No_include_functor-T.md Oxcaml-No_include_functor-T.md.gen)) + (enabled_if %{ocaml-config:ox})) (rule (alias runtest) (package odoc) diff --git a/test/generators/man/Oxcaml.3o b/test/generators/man/Oxcaml.3o index 5bc2ed6e14..3b695a1fdf 100644 --- a/test/generators/man/Oxcaml.3o +++ b/test/generators/man/Oxcaml.3o @@ -682,4 +682,10 @@ Module with portable modality\. The modality is applied to all value members of contended modality applied to all definitions in the module, except the ones which have already specified this axis\. .nf .sp +.in 3 +\fB15 Include functor on signatures\fR +.in +.sp +\f[CB]module\fR No_include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp \f[CB]module\fR Include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Oxcaml.No_include_functor.3o b/test/generators/man/Oxcaml.No_include_functor.3o new file mode 100644 index 0000000000..b2604f7274 --- /dev/null +++ b/test/generators/man/Oxcaml.No_include_functor.3o @@ -0,0 +1,20 @@ + +.TH No_include_functor 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.No_include_functor +.SH Synopsis +.sp +.in 2 +\fBModule Oxcaml\.No_include_functor\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]module\fR T : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]type\fR t +.sp +\f[CB]type\fR included = Make(T)\.included diff --git a/test/generators/man/Oxcaml.No_include_functor.Make.3o b/test/generators/man/Oxcaml.No_include_functor.Make.3o new file mode 100644 index 0000000000..094a4e7ce1 --- /dev/null +++ b/test/generators/man/Oxcaml.No_include_functor.Make.3o @@ -0,0 +1,30 @@ + +.TH Make 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.No_include_functor\.Make +.SH Synopsis +.sp +.in 2 +\fBModule No_include_functor\.Make\fR +.in +.sp +.SH Documentation +.sp +.nf +.sp +.in 3 +\fB1 Parameters\fR +.in +.sp +\f[CB]module\fR T : \f[CB]sig\fR +.br +.ti +2 +\f[CB]type\fR t +.br +\f[CB]end\fR +.sp +.in 3 +\fB2 Signature\fR +.in +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml.No_include_functor.T.3o b/test/generators/man/Oxcaml.No_include_functor.T.3o new file mode 100644 index 0000000000..62acf3eb80 --- /dev/null +++ b/test/generators/man/Oxcaml.No_include_functor.T.3o @@ -0,0 +1,14 @@ + +.TH T 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.No_include_functor\.T +.SH Synopsis +.sp +.in 2 +\fBModule No_include_functor\.T\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]type\fR t diff --git a/test/generators/man/oxcaml.targets b/test/generators/man/oxcaml.targets index 47608a9575..2686a0c521 100644 --- a/test/generators/man/oxcaml.targets +++ b/test/generators/man/oxcaml.targets @@ -2,5 +2,8 @@ Oxcaml.3o Oxcaml.M1.3o Oxcaml.M2.3o Oxcaml.M3.3o +Oxcaml.No_include_functor.3o +Oxcaml.No_include_functor.Make.3o +Oxcaml.No_include_functor.T.3o Oxcaml.Include_functor.3o Oxcaml.Include_functor.Make.3o diff --git a/test/generators/markdown/Oxcaml-No_include_functor-Make-argument-1-T.md b/test/generators/markdown/Oxcaml-No_include_functor-Make-argument-1-T.md new file mode 100644 index 0000000000..9459dc695c --- /dev/null +++ b/test/generators/markdown/Oxcaml-No_include_functor-Make-argument-1-T.md @@ -0,0 +1,6 @@ + +# Parameter `Make.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-No_include_functor-Make.md b/test/generators/markdown/Oxcaml-No_include_functor-Make.md new file mode 100644 index 0000000000..552520f632 --- /dev/null +++ b/test/generators/markdown/Oxcaml-No_include_functor-Make.md @@ -0,0 +1,15 @@ + +# Module `No_include_functor.Make` + + +## Parameters + +```ocaml +module T : sig ... end +``` + +## Signature + +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-No_include_functor-T.md b/test/generators/markdown/Oxcaml-No_include_functor-T.md new file mode 100644 index 0000000000..af326e0804 --- /dev/null +++ b/test/generators/markdown/Oxcaml-No_include_functor-T.md @@ -0,0 +1,6 @@ + +# Module `No_include_functor.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-No_include_functor.md b/test/generators/markdown/Oxcaml-No_include_functor.md new file mode 100644 index 0000000000..3f948350f1 --- /dev/null +++ b/test/generators/markdown/Oxcaml-No_include_functor.md @@ -0,0 +1,15 @@ + +# Module `Oxcaml.No_include_functor` + +```ocaml +module Make (T : sig ... end) : sig ... end +``` +```ocaml +module T : sig ... end +``` +```ocaml +type t +``` +```ocaml +type included = Make(T).included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml.md b/test/generators/markdown/Oxcaml.md index 29d93b8584..a722b5c1b0 100644 --- a/test/generators/markdown/Oxcaml.md +++ b/test/generators/markdown/Oxcaml.md @@ -346,6 +346,12 @@ module M3 : sig ... end ``` `contended` modality applied to all definitions in the module, except the ones which have already specified this axis. + +## Include functor on signatures + +```ocaml +module No_include_functor : sig ... end +``` ```ocaml module Include_functor : sig ... end ``` \ No newline at end of file diff --git a/test/generators/markdown/oxcaml.targets b/test/generators/markdown/oxcaml.targets index 101eec5c37..1fa2a3c0dd 100644 --- a/test/generators/markdown/oxcaml.targets +++ b/test/generators/markdown/oxcaml.targets @@ -3,6 +3,10 @@ Oxcaml-module-type-S.md Oxcaml-M1.md Oxcaml-M2.md Oxcaml-M3.md +Oxcaml-No_include_functor.md +Oxcaml-No_include_functor-Make.md +Oxcaml-No_include_functor-Make-argument-1-T.md +Oxcaml-No_include_functor-T.md Oxcaml-Include_functor.md Oxcaml-Include_functor-Make.md Oxcaml-Include_functor-Make-argument-1-T.md From 96e1713f01b125e7bd2f37fe6002925a35bfbfff Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Fri, 12 Jun 2026 16:18:09 +0200 Subject: [PATCH 3/7] Add "include functor" rendering --- src/document/generator.ml | 14 +++++++++---- src/loader/cmti.ml | 10 ++++++++- src/model/lang.ml | 5 +++-- src/model_desc/lang_desc.ml | 1 + src/xref2/compile.ml | 9 +++++++- src/xref2/component.ml | 4 +++- src/xref2/component.mli | 2 +- src/xref2/lang_of.ml | 1 + src/xref2/link.ml | 2 ++ src/xref2/subst.ml | 1 + src/xref2/tools.ml | 10 +++++++++ src/xref2/tools.mli | 2 ++ .../html/Oxcaml-Include_functor.html | 21 ++++++++++++++----- test/generators/latex/Oxcaml.tex | 2 +- 14 files changed, 68 insertions(+), 16 deletions(-) diff --git a/src/document/generator.ml b/src/document/generator.ml index 0133714b0f..977124edc0 100644 --- a/src/document/generator.ml +++ b/src/document/generator.ml @@ -1916,7 +1916,7 @@ module Make (Syntax : SYNTAX) = struct and include_ (t : Odoc_model.Lang.Include.t) = let decl_hidden = match t.decl with - | Alias p -> Paths.Path.(is_hidden (p :> t)) + | Alias p | Functor p -> Paths.Path.(is_hidden (p :> t)) | ModuleType mty -> umty_hidden mty in let status = if decl_hidden then `Inline else t.status in @@ -1925,14 +1925,20 @@ module Make (Syntax : SYNTAX) = struct let summary = if decl_hidden then O.render (O.keyword "include" ++ O.txt " ...") else - let include_decl = + let include_kw, include_decl = match t.decl with | Odoc_model.Lang.Include.Alias mod_path -> + O.keyword "include", Link.from_path (mod_path :> Paths.Path.t) - | ModuleType mt -> umty mt + | Functor mod_path -> + O.keyword "include functor", + Link.from_path (mod_path :> Paths.Path.t) + | ModuleType mt -> + O.keyword "include", + umty mt in O.render - (O.keyword "include" ++ O.txt " " ++ include_decl + (include_kw ++ O.txt " " ++ include_decl ++ if Syntax.Mod.include_semicolon then O.keyword ";" else O.noop) in let content = { Include.content; status; summary } in diff --git a/src/loader/cmti.ml b/src/loader/cmti.ml index a5200ae3b5..a14f91e8ca 100644 --- a/src/loader/cmti.ml +++ b/src/loader/cmti.ml @@ -965,8 +965,16 @@ and read_include env parent incl = #endif let decl = Include.ModuleType uexpr in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] +#if defined OXCAML + | Some uexpr, (Tincl_functor _ | Tincl_gen_functor _) -> + let p = match uexpr with + | TypeOf (ModPath p, _) -> p + | _ -> failwith "We expected TypeOf with a ModPath but got something else" + in + let decl = Include.Functor p in + [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] +#endif | _ -> - (* TODO: Handle [include functor] *) content.items and read_open env parent o = diff --git a/src/model/lang.ml b/src/model/lang.ml index 4fe5b890ae..ec23399b7e 100644 --- a/src/model/lang.ml +++ b/src/model/lang.ml @@ -196,7 +196,7 @@ and Include : sig type expansion = { shadowed : shadowed; content : Signature.t } (* Explicitly unexpanded decl *) - type decl = Alias of Path.Module.t | ModuleType of ModuleType.U.expr + type decl = Alias of Path.Module.t | ModuleType of ModuleType.U.expr | Functor of Path.Module.t type t = { loc : Location_.span; @@ -632,7 +632,8 @@ let extract_signature_doc (s : Signature.t) = (* A signature that starts with an include may inherits the top-comment from the expansion. *) | { Include.status = `Inline; _ } -> true - | { decl = Alias p; _ } -> Paths.Path.is_hidden (p :> Path.t) + | { decl = Alias p; _ } + | { decl = Functor p; _ } -> Paths.Path.is_hidden (p :> Path.t) | { decl = ModuleType expr; _ } -> uexpr_considered_hidden expr in match (s.doc, s.items) with diff --git a/src/model_desc/lang_desc.ml b/src/model_desc/lang_desc.ml index 75e9bcf7e3..931661c296 100644 --- a/src/model_desc/lang_desc.ml +++ b/src/model_desc/lang_desc.ml @@ -293,6 +293,7 @@ and include_decl = Variant (function | Alias p -> C ("Alias", (p :> Paths.Path.t), path) + | Functor p -> C ("Functor", (p :> Paths.Path.t), path) | ModuleType e -> C ("ModuleType", e, moduletype_u_expr)) and include_expansion = diff --git a/src/xref2/compile.ml b/src/xref2/compile.ml index a6dd9a101d..8101c4ed7d 100644 --- a/src/xref2/compile.ml +++ b/src/xref2/compile.ml @@ -389,6 +389,9 @@ and include_decl : Env.t -> Id.Signature.t -> Include.decl -> Include.decl = | ModuleType expr -> if is_elidable_with_module_type_u expr then ModuleType expr else ModuleType (u_module_type_expr env id expr) + | Functor p -> + (* TODO deduplicate *) + Functor (module_path env p) | Alias p -> Alias (module_path env p) and module_type : Env.t -> ModuleType.t -> ModuleType.t = @@ -410,10 +413,14 @@ and include_ : Env.t -> Include.t -> Include.t * Env.t = match let open Odoc_utils.ResultMonad in match decl with + | Functor p -> + Tools.expansion_of_module_path env ~strengthen:true p >>= fun exp -> + Tools.assert_functor exp | Alias p -> Tools.expansion_of_module_path env ~strengthen:true p >>= fun exp -> Tools.assert_not_functor exp - | ModuleType mty -> Tools.signature_of_u_module_type_expr env mty + | ModuleType mty -> + Tools.signature_of_u_module_type_expr env mty with | Error e -> Errors.report ~what:(`Include decl) ~tools_error:e `Expand; diff --git a/src/xref2/component.ml b/src/xref2/component.ml index be23a7b3ea..4c61e12250 100644 --- a/src/xref2/component.ml +++ b/src/xref2/component.ml @@ -364,7 +364,7 @@ end = Open and Include : sig - type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr + type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr | Functor of Cpath.module_ type t = { parent : Odoc_model.Paths.Identifier.Signature.t; @@ -924,6 +924,7 @@ module Fmt = struct let open Include in function | Alias p -> Format.fprintf ppf "%a" (module_path c) p + | Functor p -> Format.fprintf ppf "functor %a" (module_path c) p | ModuleType mt -> Format.fprintf ppf "%a" (u_module_type_expr c) mt and value c ppf v = @@ -2410,6 +2411,7 @@ module Of_Lang = struct and include_decl ident_map m = match m with | Odoc_model.Lang.Include.Alias p -> Include.Alias (module_path ident_map p) + | Functor p -> Functor (module_path ident_map p) | ModuleType s -> ModuleType (u_module_type_expr ident_map s) and simple_expansion ident_map diff --git a/src/xref2/component.mli b/src/xref2/component.mli index abda54e140..19c7c10a5f 100644 --- a/src/xref2/component.mli +++ b/src/xref2/component.mli @@ -336,7 +336,7 @@ and Open : sig end and Include : sig - type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr + type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr | Functor of Cpath.module_ type t = { parent : Odoc_model.Paths.Identifier.Signature.t; diff --git a/src/xref2/lang_of.ml b/src/xref2/lang_of.ml index 5c49cb96c9..cea2df341e 100644 --- a/src/xref2/lang_of.ml +++ b/src/xref2/lang_of.ml @@ -651,6 +651,7 @@ and include_decl : (* Don't start shadowing within any signatures *) match d with | Alias p -> Alias (Path.module_ map p) + | Functor p -> Functor (Path.module_ map p) | ModuleType mty -> let include_parent = Identifier.fresh_include_parent identifier in ModuleType (u_module_type_expr map include_parent mty) diff --git a/src/xref2/link.ml b/src/xref2/link.ml index bd332ee691..4ac1aada2f 100644 --- a/src/xref2/link.ml +++ b/src/xref2/link.ml @@ -707,6 +707,8 @@ and include_decl : Env.t -> Id.Signature.t -> Include.decl -> Include.decl = match decl with | ModuleType expr when is_elidable_with_module_type_u expr -> ModuleType expr | ModuleType expr -> ModuleType (u_module_type_expr env id expr) + (* TODO dedup *) + | Functor p -> Functor (module_path env p) | Alias p -> Alias (module_path env p) and module_type : Env.t -> ModuleType.t -> ModuleType.t = diff --git a/src/xref2/subst.ml b/src/xref2/subst.ml index 49bbf0205e..9e7a305257 100644 --- a/src/xref2/subst.ml +++ b/src/xref2/subst.ml @@ -759,6 +759,7 @@ and module_decl s t = and include_decl s t = match t with | Include.Alias p -> Include.Alias (module_path s p) + | Functor p -> Functor (module_path s p) | ModuleType t -> ModuleType (u_module_type_expr s t) and module_ s t = diff --git a/src/xref2/tools.ml b/src/xref2/tools.ml index a560ec01cc..12ad115ee8 100644 --- a/src/xref2/tools.ml +++ b/src/xref2/tools.ml @@ -1586,6 +1586,12 @@ and assert_not_functor : type err. | Signature sg -> Ok sg | _ -> assert false +and assert_functor : type err. expansion -> (Component.Signature.t, err) result + = function + | Functor (_, mty) -> ( + match mty with Signature s -> Ok s | _ -> assert false) + | _ -> assert false + and unresolve_subs subs = List.map (function @@ -1812,6 +1818,10 @@ and fragmap : expansion_of_module_path env ~strengthen:true p >>= assert_not_functor >>= fun sg -> fragmap env subst sg >>= fun sg -> Ok (ModuleType (Signature sg)) + | Functor p -> + expansion_of_module_path env ~strengthen:true p >>= assert_functor + >>= fun sg -> + fragmap env subst sg >>= fun sg -> Ok (ModuleType (Signature sg)) | ModuleType mty' -> Ok (ModuleType (With ([ subst ], mty'))) in let map_module m new_subst = diff --git a/src/xref2/tools.mli b/src/xref2/tools.mli index 81c1322c42..7b3fb06647 100644 --- a/src/xref2/tools.mli +++ b/src/xref2/tools.mli @@ -201,6 +201,8 @@ val prefix_signature : val assert_not_functor : expansion -> (Component.Signature.t, 'err) result +val assert_functor : expansion -> (Component.Signature.t, 'err) result + val expansion_of_module_path : Env.t -> strengthen:bool -> diff --git a/test/generators/html/Oxcaml-Include_functor.html b/test/generators/html/Oxcaml-Include_functor.html index f964624cb1..18eaf5f364 100644 --- a/test/generators/html/Oxcaml-Include_functor.html +++ b/test/generators/html/Oxcaml-Include_functor.html @@ -37,11 +37,22 @@

    Module Oxcaml.Include_functor

    type t
    -
    -
    - - type included -
    +
    +
    + + + include functor + Make + + + +
    +
    + + type included +
    +
    +
    diff --git a/test/generators/latex/Oxcaml.tex b/test/generators/latex/Oxcaml.tex index cc24a98e23..1c35f41037 100644 --- a/test/generators/latex/Oxcaml.tex +++ b/test/generators/latex/Oxcaml.tex @@ -251,7 +251,7 @@ \subsection{Include functor on signatures\label{Oxcaml--include-functor-on-signa \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{Oxcaml--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ \label{Oxcaml-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ -\label{Oxcaml-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\ocamltag{keyword}{include functor} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}\label{Oxcaml-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ From 2fc8c1a001bc2e5bc8bcf0c1230134ee60566c41 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Tue, 23 Jun 2026 14:44:19 +0200 Subject: [PATCH 4/7] Add example for include functor in structs Signed-off-by: Marek Kubica --- test/generators/cases/oxcaml_impl.ml | 18 ++ ...mpl-Include_functor-Make-argument-1-T.html | 31 ++++ .../Oxcaml_impl-Include_functor-Make.html | 52 ++++++ .../html/Oxcaml_impl-Include_functor.html | 49 +++++ ...-No_include_functor-Make-argument-1-T.html | 31 ++++ .../Oxcaml_impl-No_include_functor-Make.html | 52 ++++++ .../Oxcaml_impl-No_include_functor-T.html | 29 +++ .../html/Oxcaml_impl-No_include_functor.html | 98 ++++++++++ test/generators/html/Oxcaml_impl.html | 40 ++++ test/generators/html/oxcaml_impl.targets | 7 + test/generators/latex/Oxcaml_impl.tex | 14 ++ test/generators/link.dune.inc | 173 +++++++++++++++++- test/generators/man/Oxcaml_impl.3o | 8 + .../man/Oxcaml_impl.Include_functor.3o | 18 ++ .../man/Oxcaml_impl.Include_functor.Make.3o | 30 +++ .../man/Oxcaml_impl.No_include_functor.3o | 20 ++ .../Oxcaml_impl.No_include_functor.Make.3o | 30 +++ .../man/Oxcaml_impl.No_include_functor.T.3o | 14 ++ test/generators/man/oxcaml_impl.targets | 5 + ..._impl-Include_functor-Make-argument-1-T.md | 6 + .../Oxcaml_impl-Include_functor-Make.md | 15 ++ .../markdown/Oxcaml_impl-Include_functor.md | 12 ++ ...pl-No_include_functor-Make-argument-1-T.md | 6 + .../Oxcaml_impl-No_include_functor-Make.md | 15 ++ .../Oxcaml_impl-No_include_functor-T.md | 6 + .../Oxcaml_impl-No_include_functor.md | 15 ++ test/generators/markdown/Oxcaml_impl.md | 9 + test/generators/markdown/oxcaml_impl.targets | 7 + 28 files changed, 807 insertions(+), 3 deletions(-) create mode 100644 test/generators/html/Oxcaml_impl-Include_functor-Make-argument-1-T.html create mode 100644 test/generators/html/Oxcaml_impl-Include_functor-Make.html create mode 100644 test/generators/html/Oxcaml_impl-Include_functor.html create mode 100644 test/generators/html/Oxcaml_impl-No_include_functor-Make-argument-1-T.html create mode 100644 test/generators/html/Oxcaml_impl-No_include_functor-Make.html create mode 100644 test/generators/html/Oxcaml_impl-No_include_functor-T.html create mode 100644 test/generators/html/Oxcaml_impl-No_include_functor.html create mode 100644 test/generators/man/Oxcaml_impl.Include_functor.3o create mode 100644 test/generators/man/Oxcaml_impl.Include_functor.Make.3o create mode 100644 test/generators/man/Oxcaml_impl.No_include_functor.3o create mode 100644 test/generators/man/Oxcaml_impl.No_include_functor.Make.3o create mode 100644 test/generators/man/Oxcaml_impl.No_include_functor.T.3o create mode 100644 test/generators/markdown/Oxcaml_impl-Include_functor-Make-argument-1-T.md create mode 100644 test/generators/markdown/Oxcaml_impl-Include_functor-Make.md create mode 100644 test/generators/markdown/Oxcaml_impl-Include_functor.md create mode 100644 test/generators/markdown/Oxcaml_impl-No_include_functor-Make-argument-1-T.md create mode 100644 test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md create mode 100644 test/generators/markdown/Oxcaml_impl-No_include_functor-T.md create mode 100644 test/generators/markdown/Oxcaml_impl-No_include_functor.md diff --git a/test/generators/cases/oxcaml_impl.ml b/test/generators/cases/oxcaml_impl.ml index 351121dbe1..cdff2e51cb 100644 --- a/test/generators/cases/oxcaml_impl.ml +++ b/test/generators/cases/oxcaml_impl.ml @@ -8,3 +8,21 @@ end module Including = struct include To_be_included end + +(** {1 Include functor on structures} *) + +module No_include_functor = struct + module Make (T : sig type t end) = struct type included end + module T = struct + type t + end + + include T + include Make(T) +end + +module Include_functor = struct + module Make (T : sig type t end) = struct type included end + type t + include functor Make +end diff --git a/test/generators/html/Oxcaml_impl-Include_functor-Make-argument-1-T.html b/test/generators/html/Oxcaml_impl-Include_functor-Make-argument-1-T.html new file mode 100644 index 0000000000..89b5389e1f --- /dev/null +++ b/test/generators/html/Oxcaml_impl-Include_functor-Make-argument-1-T.html @@ -0,0 +1,31 @@ + + + T (Oxcaml_impl.Include_functor.Make.T) + + + + + + + + +
    +

    Parameter Make.T

    +
    +
    +
    +
    + + type t +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-Include_functor-Make.html b/test/generators/html/Oxcaml_impl-Include_functor-Make.html new file mode 100644 index 0000000000..63fd3d57ca --- /dev/null +++ b/test/generators/html/Oxcaml_impl-Include_functor-Make.html @@ -0,0 +1,52 @@ + + + Make (Oxcaml_impl.Include_functor.Make) + + + + + + + + +
    +

    Module Include_functor.Make

    +
    +
    + +
    +
    +

    Parameters +

    +
    +
    + + module + + T + + : sig ... + end + + +
    +
    +

    Signature

    +
    +
    + + type included +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-Include_functor.html b/test/generators/html/Oxcaml_impl-Include_functor.html new file mode 100644 index 0000000000..b991958ed1 --- /dev/null +++ b/test/generators/html/Oxcaml_impl-Include_functor.html @@ -0,0 +1,49 @@ + + + Include_functor (Oxcaml_impl.Include_functor) + + + + + + + + +
    +

    Module Oxcaml_impl.Include_functor

    +
    +
    +
    +
    + + + module + Make + + ( + T + : sig ... + end) : sig + ... end + + +
    +
    +
    +
    + + type t +
    +
    +
    +
    + + type included +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-No_include_functor-Make-argument-1-T.html b/test/generators/html/Oxcaml_impl-No_include_functor-Make-argument-1-T.html new file mode 100644 index 0000000000..cc2e3dc5a6 --- /dev/null +++ b/test/generators/html/Oxcaml_impl-No_include_functor-Make-argument-1-T.html @@ -0,0 +1,31 @@ + + + T (Oxcaml_impl.No_include_functor.Make.T) + + + + + + + + +
    +

    Parameter Make.T

    +
    +
    +
    +
    + + type t +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-No_include_functor-Make.html b/test/generators/html/Oxcaml_impl-No_include_functor-Make.html new file mode 100644 index 0000000000..f27582db18 --- /dev/null +++ b/test/generators/html/Oxcaml_impl-No_include_functor-Make.html @@ -0,0 +1,52 @@ + + + Make (Oxcaml_impl.No_include_functor.Make) + + + + + + + + +
    +

    Module No_include_functor.Make

    +
    +
    + +
    +
    +

    Parameters +

    +
    +
    + + module + + T + + : sig ... + end + + +
    +
    +

    Signature

    +
    +
    + + type included +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-No_include_functor-T.html b/test/generators/html/Oxcaml_impl-No_include_functor-T.html new file mode 100644 index 0000000000..78f282a825 --- /dev/null +++ b/test/generators/html/Oxcaml_impl-No_include_functor-T.html @@ -0,0 +1,29 @@ + + + T (Oxcaml_impl.No_include_functor.T) + + + + + + + + +
    +

    Module No_include_functor.T

    +
    +
    +
    +
    + + type t +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl-No_include_functor.html b/test/generators/html/Oxcaml_impl-No_include_functor.html new file mode 100644 index 0000000000..66f5244334 --- /dev/null +++ b/test/generators/html/Oxcaml_impl-No_include_functor.html @@ -0,0 +1,98 @@ + + + No_include_functor (Oxcaml_impl.No_include_functor) + + + + + + + + +
    +

    Module Oxcaml_impl.No_include_functor

    +
    +
    +
    +
    + + + module + Make + + ( + T + : sig ... + end) : sig + ... end + + +
    +
    +
    +
    + + + module + T + + : sig ... + end + + +
    +
    +
    +
    + + + include + module type + of struct + include + T + end + + + +
    +
    + + type t + = + T.t + + +
    +
    +
    +
    +
    +
    + + + include + sig ... end + + + +
    +
    + + type included + = + + Make(T).included + + + +
    +
    +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml_impl.html b/test/generators/html/Oxcaml_impl.html index 285dc626a8..ad934c42c6 100644 --- a/test/generators/html/Oxcaml_impl.html +++ b/test/generators/html/Oxcaml_impl.html @@ -14,6 +14,16 @@

    Module Oxcaml_impl

    +
    @@ -54,6 +64,36 @@

    Module Oxcaml_impl

    +

    + Include + functor on structures +

    +
    +
    + + + module + No_include_functor + + : sig ... + end + + +
    +
    +
    +
    + + + module + Include_functor + + : sig ... + end + + +
    +
    diff --git a/test/generators/html/oxcaml_impl.targets b/test/generators/html/oxcaml_impl.targets index 0b5d029cba..72c2b4911e 100644 --- a/test/generators/html/oxcaml_impl.targets +++ b/test/generators/html/oxcaml_impl.targets @@ -1,3 +1,10 @@ Oxcaml_impl.html Oxcaml_impl-To_be_included.html Oxcaml_impl-Including.html +Oxcaml_impl-No_include_functor.html +Oxcaml_impl-No_include_functor-Make.html +Oxcaml_impl-No_include_functor-Make-argument-1-T.html +Oxcaml_impl-No_include_functor-T.html +Oxcaml_impl-Include_functor.html +Oxcaml_impl-Include_functor-Make.html +Oxcaml_impl-Include_functor-Make-argument-1-T.html diff --git a/test/generators/latex/Oxcaml_impl.tex b/test/generators/latex/Oxcaml_impl.tex index 149a39e20c..0f2b333f50 100644 --- a/test/generators/latex/Oxcaml_impl.tex +++ b/test/generators/latex/Oxcaml_impl.tex @@ -6,5 +6,19 @@ \section{Module \ocamlinlinecode{Oxcaml\_\allowbreak{}impl}}\label{Oxcaml_impl}% \label{Oxcaml_impl--module-Including}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Including]{\ocamlinlinecode{Including}}}\label{Oxcaml_impl-Including}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\ocamltag{keyword}{include} \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \ocamltag{keyword}{struct} \ocamltag{keyword}{include} \hyperref[Oxcaml_impl-To_be_included]{\ocamlinlinecode{To\_\allowbreak{}be\_\allowbreak{}included}} \ocamltag{keyword}{end}\label{Oxcaml_impl-Including--val-add}\ocamlcodefragment{\ocamltag{keyword}{val} add : bool \ocamltag{arrow}{$\rightarrow$} int \ocamltag{arrow}{$\rightarrow$} int \ocamltag{arrow}{$\rightarrow$} int [@@zero\_\allowbreak{}alloc]}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\subsection{Include functor on structures\label{Oxcaml_impl--include-functor-on-structures}}% +\label{Oxcaml_impl--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml_impl-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml_impl-No_include_functor--module-T}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor-T]{\ocamlinlinecode{T}}}\label{Oxcaml_impl-No_include_functor-T}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-No_include_functor-T--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\ocamltag{keyword}{include} \ocamltag{keyword}{module} \ocamltag{keyword}{type} \ocamltag{keyword}{of} \ocamltag{keyword}{struct} \ocamltag{keyword}{include} \hyperref[Oxcaml_impl-No_include_functor-T]{\ocamlinlinecode{T}} \ocamltag{keyword}{end}\label{Oxcaml_impl-No_include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t = \hyperref[Oxcaml_impl-No_include_functor-T--type-t]{\ocamlinlinecode{T.\allowbreak{}t}}}\\ +\ocamltag{keyword}{include} \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}\label{Oxcaml_impl-No_include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included = \hyperref[Oxcaml_impl-No_include_functor-Make--type-included]{\ocamlinlinecode{Make(T).\allowbreak{}included}}}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\label{Oxcaml_impl--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml_impl-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml_impl-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\label{Oxcaml_impl-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ diff --git a/test/generators/link.dune.inc b/test/generators/link.dune.inc index ff3418e7d8..43e8390e8f 100644 --- a/test/generators/link.dune.inc +++ b/test/generators/link.dune.inc @@ -12330,7 +12330,14 @@ (targets Oxcaml_impl.html.gen Oxcaml_impl-To_be_included.html.gen - Oxcaml_impl-Including.html.gen) + Oxcaml_impl-Including.html.gen + Oxcaml_impl-No_include_functor.html.gen + Oxcaml_impl-No_include_functor-Make.html.gen + Oxcaml_impl-No_include_functor-Make-argument-1-T.html.gen + Oxcaml_impl-No_include_functor-T.html.gen + Oxcaml_impl-Include_functor.html.gen + Oxcaml_impl-Include_functor-Make.html.gen + Oxcaml_impl-Include_functor-Make-argument-1-T.html.gen) (package odoc) (action (run @@ -12361,6 +12368,62 @@ (package odoc) (action (diff Oxcaml_impl-Including.html Oxcaml_impl-Including.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor.html + Oxcaml_impl-No_include_functor.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-Make.html + Oxcaml_impl-No_include_functor-Make.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-Make-argument-1-T.html + Oxcaml_impl-No_include_functor-Make-argument-1-T.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-T.html + Oxcaml_impl-No_include_functor-T.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-Include_functor.html + Oxcaml_impl-Include_functor.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-Include_functor-Make.html + Oxcaml_impl-Include_functor-Make.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-Include_functor-Make-argument-1-T.html + Oxcaml_impl-Include_functor-Make-argument-1-T.html.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12425,7 +12488,12 @@ (targets Oxcaml_impl.3o.gen Oxcaml_impl.To_be_included.3o.gen - Oxcaml_impl.Including.3o.gen) + Oxcaml_impl.Including.3o.gen + Oxcaml_impl.No_include_functor.3o.gen + Oxcaml_impl.No_include_functor.Make.3o.gen + Oxcaml_impl.No_include_functor.T.3o.gen + Oxcaml_impl.Include_functor.3o.gen + Oxcaml_impl.Include_functor.Make.3o.gen) (package odoc) (action (run @@ -12454,6 +12522,44 @@ (package odoc) (action (diff Oxcaml_impl.Including.3o Oxcaml_impl.Including.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl.No_include_functor.3o + Oxcaml_impl.No_include_functor.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl.No_include_functor.Make.3o + Oxcaml_impl.No_include_functor.Make.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl.No_include_functor.T.3o + Oxcaml_impl.No_include_functor.T.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml_impl.Include_functor.3o Oxcaml_impl.Include_functor.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl.Include_functor.Make.3o + Oxcaml_impl.Include_functor.Make.3o.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12479,7 +12585,14 @@ (targets Oxcaml_impl.md.gen Oxcaml_impl-To_be_included.md.gen - Oxcaml_impl-Including.md.gen) + Oxcaml_impl-Including.md.gen + Oxcaml_impl-No_include_functor.md.gen + Oxcaml_impl-No_include_functor-Make.md.gen + Oxcaml_impl-No_include_functor-Make-argument-1-T.md.gen + Oxcaml_impl-No_include_functor-T.md.gen + Oxcaml_impl-Include_functor.md.gen + Oxcaml_impl-Include_functor-Make.md.gen + Oxcaml_impl-Include_functor-Make-argument-1-T.md.gen) (package odoc) (action (run @@ -12508,6 +12621,60 @@ (package odoc) (action (diff Oxcaml_impl-Including.md Oxcaml_impl-Including.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor.md + Oxcaml_impl-No_include_functor.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-Make.md + Oxcaml_impl-No_include_functor-Make.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-Make-argument-1-T.md + Oxcaml_impl-No_include_functor-Make-argument-1-T.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-No_include_functor-T.md + Oxcaml_impl-No_include_functor-T.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff Oxcaml_impl-Include_functor.md Oxcaml_impl-Include_functor.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-Include_functor-Make.md + Oxcaml_impl-Include_functor-Make.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml_impl-Include_functor-Make-argument-1-T.md + Oxcaml_impl-Include_functor-Make-argument-1-T.md.gen)) (enabled_if %{ocaml-config:ox}))) (subdir diff --git a/test/generators/man/Oxcaml_impl.3o b/test/generators/man/Oxcaml_impl.3o index c73fcd111f..ee701dd1db 100644 --- a/test/generators/man/Oxcaml_impl.3o +++ b/test/generators/man/Oxcaml_impl.3o @@ -16,3 +16,11 @@ Oxcaml_impl \f[CB]module\fR To_be_included : \f[CB]sig\fR \.\.\. \f[CB]end\fR .sp \f[CB]module\fR Including : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +.in 3 +\fB1 Include functor on structures\fR +.in +.sp +\f[CB]module\fR No_include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]module\fR Include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Oxcaml_impl.Include_functor.3o b/test/generators/man/Oxcaml_impl.Include_functor.3o new file mode 100644 index 0000000000..13ecc3dc04 --- /dev/null +++ b/test/generators/man/Oxcaml_impl.Include_functor.3o @@ -0,0 +1,18 @@ + +.TH Include_functor 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml_impl\.Include_functor +.SH Synopsis +.sp +.in 2 +\fBModule Oxcaml_impl\.Include_functor\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]type\fR t +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml_impl.Include_functor.Make.3o b/test/generators/man/Oxcaml_impl.Include_functor.Make.3o new file mode 100644 index 0000000000..c65b57ad93 --- /dev/null +++ b/test/generators/man/Oxcaml_impl.Include_functor.Make.3o @@ -0,0 +1,30 @@ + +.TH Make 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml_impl\.Include_functor\.Make +.SH Synopsis +.sp +.in 2 +\fBModule Include_functor\.Make\fR +.in +.sp +.SH Documentation +.sp +.nf +.sp +.in 3 +\fB1 Parameters\fR +.in +.sp +\f[CB]module\fR T : \f[CB]sig\fR +.br +.ti +2 +\f[CB]type\fR t +.br +\f[CB]end\fR +.sp +.in 3 +\fB2 Signature\fR +.in +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml_impl.No_include_functor.3o b/test/generators/man/Oxcaml_impl.No_include_functor.3o new file mode 100644 index 0000000000..f5f9d6b80b --- /dev/null +++ b/test/generators/man/Oxcaml_impl.No_include_functor.3o @@ -0,0 +1,20 @@ + +.TH No_include_functor 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml_impl\.No_include_functor +.SH Synopsis +.sp +.in 2 +\fBModule Oxcaml_impl\.No_include_functor\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]module\fR T : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]type\fR t = T\.t +.sp +\f[CB]type\fR included = Make(T)\.included diff --git a/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o b/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o new file mode 100644 index 0000000000..117a283d5c --- /dev/null +++ b/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o @@ -0,0 +1,30 @@ + +.TH Make 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml_impl\.No_include_functor\.Make +.SH Synopsis +.sp +.in 2 +\fBModule No_include_functor\.Make\fR +.in +.sp +.SH Documentation +.sp +.nf +.sp +.in 3 +\fB1 Parameters\fR +.in +.sp +\f[CB]module\fR T : \f[CB]sig\fR +.br +.ti +2 +\f[CB]type\fR t +.br +\f[CB]end\fR +.sp +.in 3 +\fB2 Signature\fR +.in +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml_impl.No_include_functor.T.3o b/test/generators/man/Oxcaml_impl.No_include_functor.T.3o new file mode 100644 index 0000000000..96dd994d78 --- /dev/null +++ b/test/generators/man/Oxcaml_impl.No_include_functor.T.3o @@ -0,0 +1,14 @@ + +.TH T 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml_impl\.No_include_functor\.T +.SH Synopsis +.sp +.in 2 +\fBModule No_include_functor\.T\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]type\fR t diff --git a/test/generators/man/oxcaml_impl.targets b/test/generators/man/oxcaml_impl.targets index d0f3634ab4..e012c68915 100644 --- a/test/generators/man/oxcaml_impl.targets +++ b/test/generators/man/oxcaml_impl.targets @@ -1,3 +1,8 @@ Oxcaml_impl.3o Oxcaml_impl.To_be_included.3o Oxcaml_impl.Including.3o +Oxcaml_impl.No_include_functor.3o +Oxcaml_impl.No_include_functor.Make.3o +Oxcaml_impl.No_include_functor.T.3o +Oxcaml_impl.Include_functor.3o +Oxcaml_impl.Include_functor.Make.3o diff --git a/test/generators/markdown/Oxcaml_impl-Include_functor-Make-argument-1-T.md b/test/generators/markdown/Oxcaml_impl-Include_functor-Make-argument-1-T.md new file mode 100644 index 0000000000..9459dc695c --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-Include_functor-Make-argument-1-T.md @@ -0,0 +1,6 @@ + +# Parameter `Make.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md b/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md new file mode 100644 index 0000000000..717336f028 --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md @@ -0,0 +1,15 @@ + +# Module `Include_functor.Make` + + +## Parameters + +```ocaml +module T : sig ... end +``` + +## Signature + +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-Include_functor.md b/test/generators/markdown/Oxcaml_impl-Include_functor.md new file mode 100644 index 0000000000..854486cfe2 --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-Include_functor.md @@ -0,0 +1,12 @@ + +# Module `Oxcaml_impl.Include_functor` + +```ocaml +module Make (T : sig ... end) : sig ... end +``` +```ocaml +type t +``` +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor-Make-argument-1-T.md b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make-argument-1-T.md new file mode 100644 index 0000000000..9459dc695c --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make-argument-1-T.md @@ -0,0 +1,6 @@ + +# Parameter `Make.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md new file mode 100644 index 0000000000..552520f632 --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md @@ -0,0 +1,15 @@ + +# Module `No_include_functor.Make` + + +## Parameters + +```ocaml +module T : sig ... end +``` + +## Signature + +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor-T.md b/test/generators/markdown/Oxcaml_impl-No_include_functor-T.md new file mode 100644 index 0000000000..af326e0804 --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor-T.md @@ -0,0 +1,6 @@ + +# Module `No_include_functor.T` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor.md b/test/generators/markdown/Oxcaml_impl-No_include_functor.md new file mode 100644 index 0000000000..1ad27ff002 --- /dev/null +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor.md @@ -0,0 +1,15 @@ + +# Module `Oxcaml_impl.No_include_functor` + +```ocaml +module Make (T : sig ... end) : sig ... end +``` +```ocaml +module T : sig ... end +``` +```ocaml +type t = T.t +``` +```ocaml +type included = Make(T).included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl.md b/test/generators/markdown/Oxcaml_impl.md index f903a30efd..26366c6320 100644 --- a/test/generators/markdown/Oxcaml_impl.md +++ b/test/generators/markdown/Oxcaml_impl.md @@ -9,4 +9,13 @@ module To_be_included : sig ... end ``` ```ocaml module Including : sig ... end +``` + +## Include functor on structures + +```ocaml +module No_include_functor : sig ... end +``` +```ocaml +module Include_functor : sig ... end ``` \ No newline at end of file diff --git a/test/generators/markdown/oxcaml_impl.targets b/test/generators/markdown/oxcaml_impl.targets index 1125335e87..9f7542eb16 100644 --- a/test/generators/markdown/oxcaml_impl.targets +++ b/test/generators/markdown/oxcaml_impl.targets @@ -1,3 +1,10 @@ Oxcaml_impl.md Oxcaml_impl-To_be_included.md Oxcaml_impl-Including.md +Oxcaml_impl-No_include_functor.md +Oxcaml_impl-No_include_functor-Make.md +Oxcaml_impl-No_include_functor-Make-argument-1-T.md +Oxcaml_impl-No_include_functor-T.md +Oxcaml_impl-Include_functor.md +Oxcaml_impl-Include_functor-Make.md +Oxcaml_impl-Include_functor-Make-argument-1-T.md From 9d4fe587bfee50667b295f2aa1a9360609810b27 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Wed, 24 Jun 2026 11:01:38 +0200 Subject: [PATCH 5/7] Implement reference to include functor --- src/loader/cmt.ml | 15 +++++++------ .../html/Oxcaml_impl-Include_functor.html | 21 ++++++++++++++----- test/generators/latex/Oxcaml_impl.tex | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/loader/cmt.ml b/src/loader/cmt.ml index 7de18c4296..97d8a2fc70 100644 --- a/src/loader/cmt.ml +++ b/src/loader/cmt.ml @@ -613,26 +613,29 @@ and read_include env parent incl = let decl_modty = #if defined OXCAML match unwrap_module_expr_desc incl.incl_mod.mod_desc, incl.incl_kind with - | _, (Tincl_functor _ | Tincl_gen_functor _) -> - (* TODO: Handle [include functor] *) - None + | Tmod_ident (p, _), (Tincl_functor _ | Tincl_gen_functor _) -> ( + let p = Env.Path.read_module env.ident_env p in + Some (`Functor p)) | Tmod_ident(p, _), Tincl_structure -> #else match unwrap_module_expr_desc incl.incl_mod.mod_desc with | Tmod_ident(p, _) -> #endif let p = Env.Path.read_module env.ident_env p in - Some (ModuleType.U.TypeOf (ModuleType.StructInclude p, p)) + Some (`Module_type (ModuleType.U.TypeOf (ModuleType.StructInclude p, p))) | _ -> let mty = read_module_expr env parent container incl.incl_mod in - umty_of_mty mty + umty_of_mty mty |> Option.map (fun m -> `Module_type m) in let content, shadowed = Cmi.read_signature_noenv env parent (Odoc_model.Compat.signature incl.incl_type) in let expansion = { content; shadowed; } in match decl_modty with - | Some m -> + | Some `Module_type m -> let decl = ModuleType m in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] + | Some `Functor p -> + let decl = Include.Functor p in + [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] | _ -> content.items diff --git a/test/generators/html/Oxcaml_impl-Include_functor.html b/test/generators/html/Oxcaml_impl-Include_functor.html index b991958ed1..4f04c241a4 100644 --- a/test/generators/html/Oxcaml_impl-Include_functor.html +++ b/test/generators/html/Oxcaml_impl-Include_functor.html @@ -38,11 +38,22 @@

    Module Oxcaml_impl.Include_functor

    type t -
    -
    - - type included -
    +
    +
    + + + include functor + Make + + + +
    +
    + + type included +
    +
    +
    diff --git a/test/generators/latex/Oxcaml_impl.tex b/test/generators/latex/Oxcaml_impl.tex index 0f2b333f50..4ed3e70565 100644 --- a/test/generators/latex/Oxcaml_impl.tex +++ b/test/generators/latex/Oxcaml_impl.tex @@ -17,7 +17,7 @@ \subsection{Include functor on structures\label{Oxcaml_impl--include-functor-on- \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \label{Oxcaml_impl--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml_impl-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ \label{Oxcaml_impl-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ -\label{Oxcaml_impl-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\ocamltag{keyword}{include functor} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}\label{Oxcaml_impl-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ From d1446e91fe23247fdc7b2827cec2130e0e214015 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Tue, 30 Jun 2026 10:31:13 +0200 Subject: [PATCH 6/7] Allow `include functor` with a module expression --- src/document/generator.ml | 18 ++--- src/loader/cmt.ml | 2 +- src/loader/cmti.ml | 8 +- src/model/lang.ml | 12 ++- src/model_desc/lang_desc.ml | 3 +- src/xref2/compile.ml | 19 +++-- src/xref2/component.ml | 14 +++- src/xref2/component.mli | 6 +- src/xref2/lang_of.ml | 5 +- src/xref2/link.ml | 13 +++- src/xref2/subst.ml | 3 +- src/xref2/tools.ml | 25 +++++-- src/xref2/tools.mli | 1 + test/generators/cases/oxcaml.mli | 10 +++ test/generators/cases/oxcaml_impl.ml | 3 + .../html/Oxcaml-Include_functor-Make.html | 3 + .../html/Oxcaml-Include_functor.html | 5 ++ ...ed_type-module-type-Make-argument-1-_.html | 33 +++++++++ ...e_functor_named_type-module-type-Make.html | 58 +++++++++++++++ .../Oxcaml-Include_functor_named_type.html | 74 +++++++++++++++++++ .../html/Oxcaml-No_include_functor-Make.html | 3 + .../html/Oxcaml-No_include_functor.html | 5 ++ test/generators/html/Oxcaml.html | 15 ++++ .../Oxcaml_impl-Include_functor-Make.html | 3 + .../html/Oxcaml_impl-Include_functor.html | 5 ++ .../Oxcaml_impl-No_include_functor-Make.html | 4 + .../html/Oxcaml_impl-No_include_functor.html | 6 ++ test/generators/html/oxcaml.targets | 3 + test/generators/latex/Oxcaml.tex | 19 ++++- test/generators/latex/Oxcaml_impl.tex | 6 +- test/generators/link.dune.inc | 69 ++++++++++++++++- test/generators/man/Oxcaml.3o | 2 + test/generators/man/Oxcaml.Include_functor.3o | 5 ++ .../man/Oxcaml.Include_functor.Make.3o | 3 + .../man/Oxcaml.Include_functor_named_type.3o | 45 +++++++++++ .../man/Oxcaml.No_include_functor.3o | 5 ++ .../man/Oxcaml.No_include_functor.Make.3o | 3 + .../man/Oxcaml_impl.Include_functor.3o | 5 ++ .../man/Oxcaml_impl.Include_functor.Make.3o | 3 + .../man/Oxcaml_impl.No_include_functor.3o | 5 ++ .../Oxcaml_impl.No_include_functor.Make.3o | 3 + test/generators/man/oxcaml.targets | 1 + .../markdown/Oxcaml-Include_functor-Make.md | 2 + .../markdown/Oxcaml-Include_functor.md | 2 + ...amed_type-module-type-Make-argument-1-_.md | 6 ++ ...ude_functor_named_type-module-type-Make.md | 17 +++++ .../Oxcaml-Include_functor_named_type.md | 14 ++++ .../Oxcaml-No_include_functor-Make.md | 2 + .../markdown/Oxcaml-No_include_functor.md | 2 + test/generators/markdown/Oxcaml.md | 3 + .../Oxcaml_impl-Include_functor-Make.md | 2 + .../markdown/Oxcaml_impl-Include_functor.md | 2 + .../Oxcaml_impl-No_include_functor-Make.md | 2 + .../Oxcaml_impl-No_include_functor.md | 2 + test/generators/markdown/oxcaml.targets | 3 + 55 files changed, 541 insertions(+), 51 deletions(-) create mode 100644 test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html create mode 100644 test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make.html create mode 100644 test/generators/html/Oxcaml-Include_functor_named_type.html create mode 100644 test/generators/man/Oxcaml.Include_functor_named_type.3o create mode 100644 test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md create mode 100644 test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make.md create mode 100644 test/generators/markdown/Oxcaml-Include_functor_named_type.md diff --git a/src/document/generator.ml b/src/document/generator.ml index 977124edc0..6d840e3d89 100644 --- a/src/document/generator.ml +++ b/src/document/generator.ml @@ -1916,8 +1916,8 @@ module Make (Syntax : SYNTAX) = struct and include_ (t : Odoc_model.Lang.Include.t) = let decl_hidden = match t.decl with - | Alias p | Functor p -> Paths.Path.(is_hidden (p :> t)) - | ModuleType mty -> umty_hidden mty + | Alias p | Functor (Path p) -> Paths.Path.(is_hidden (p :> t)) + | ModuleType mty | Functor (ModuleType mty) -> umty_hidden mty in let status = if decl_hidden then `Inline else t.status in @@ -1928,14 +1928,12 @@ module Make (Syntax : SYNTAX) = struct let include_kw, include_decl = match t.decl with | Odoc_model.Lang.Include.Alias mod_path -> - O.keyword "include", - Link.from_path (mod_path :> Paths.Path.t) - | Functor mod_path -> - O.keyword "include functor", - Link.from_path (mod_path :> Paths.Path.t) - | ModuleType mt -> - O.keyword "include", - umty mt + (O.keyword "include", Link.from_path (mod_path :> Paths.Path.t)) + | Functor (Path mod_path) -> + ( O.keyword "include functor", + Link.from_path (mod_path :> Paths.Path.t) ) + | Functor (ModuleType mt) -> (O.keyword "include functor", umty mt) + | ModuleType mt -> (O.keyword "include", umty mt) in O.render (include_kw ++ O.txt " " ++ include_decl diff --git a/src/loader/cmt.ml b/src/loader/cmt.ml index 97d8a2fc70..94dc3d9fb9 100644 --- a/src/loader/cmt.ml +++ b/src/loader/cmt.ml @@ -634,7 +634,7 @@ and read_include env parent incl = let decl = ModuleType m in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] | Some `Functor p -> - let decl = Include.Functor p in + let decl = Include.Functor (Path p) in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] | _ -> content.items diff --git a/src/loader/cmti.ml b/src/loader/cmti.ml index a14f91e8ca..33ef7cc95a 100644 --- a/src/loader/cmti.ml +++ b/src/loader/cmti.ml @@ -967,11 +967,11 @@ and read_include env parent incl = [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] #if defined OXCAML | Some uexpr, (Tincl_functor _ | Tincl_gen_functor _) -> - let p = match uexpr with - | TypeOf (ModPath p, _) -> p - | _ -> failwith "We expected TypeOf with a ModPath but got something else" + let decl = match uexpr with + | TypeOf (ModPath p, _) -> Include.Functor (Path p) + | Path p -> Include.Functor (ModuleType uexpr) + | _ -> failwith "We expected TypeOf or Path but got something else" in - let decl = Include.Functor p in [Include {parent; doc; decl; expansion; status; strengthened=None; loc }] #endif | _ -> diff --git a/src/model/lang.ml b/src/model/lang.ml index ec23399b7e..b791592c79 100644 --- a/src/model/lang.ml +++ b/src/model/lang.ml @@ -195,8 +195,13 @@ and Include : sig type expansion = { shadowed : shadowed; content : Signature.t } + type functor' = Path of Path.Module.t | ModuleType of ModuleType.U.expr + (* Explicitly unexpanded decl *) - type decl = Alias of Path.Module.t | ModuleType of ModuleType.U.expr | Functor of Path.Module.t + type decl = + | Alias of Path.Module.t + | ModuleType of ModuleType.U.expr + | Functor of functor' type t = { loc : Location_.span; @@ -632,8 +637,9 @@ let extract_signature_doc (s : Signature.t) = (* A signature that starts with an include may inherits the top-comment from the expansion. *) | { Include.status = `Inline; _ } -> true - | { decl = Alias p; _ } - | { decl = Functor p; _ } -> Paths.Path.is_hidden (p :> Path.t) + | { decl = Alias p; _ } | { decl = Functor (Path p); _ } -> + Paths.Path.is_hidden (p :> Path.t) + | { decl = Functor (ModuleType expr); _ } -> uexpr_considered_hidden expr | { decl = ModuleType expr; _ } -> uexpr_considered_hidden expr in match (s.doc, s.items) with diff --git a/src/model_desc/lang_desc.ml b/src/model_desc/lang_desc.ml index 931661c296..103ba28239 100644 --- a/src/model_desc/lang_desc.ml +++ b/src/model_desc/lang_desc.ml @@ -293,7 +293,8 @@ and include_decl = Variant (function | Alias p -> C ("Alias", (p :> Paths.Path.t), path) - | Functor p -> C ("Functor", (p :> Paths.Path.t), path) + | Functor (Path p) -> C ("Functor", (p :> Paths.Path.t), path) + | Functor (ModuleType e) -> C ("Functor", e, moduletype_u_expr) | ModuleType e -> C ("ModuleType", e, moduletype_u_expr)) and include_expansion = diff --git a/src/xref2/compile.ml b/src/xref2/compile.ml index 8101c4ed7d..dbb4b386f3 100644 --- a/src/xref2/compile.ml +++ b/src/xref2/compile.ml @@ -389,9 +389,10 @@ and include_decl : Env.t -> Id.Signature.t -> Include.decl -> Include.decl = | ModuleType expr -> if is_elidable_with_module_type_u expr then ModuleType expr else ModuleType (u_module_type_expr env id expr) - | Functor p -> - (* TODO deduplicate *) - Functor (module_path env p) + | Functor (Path p) -> Functor (Path (module_path env p)) + | Functor (ModuleType expr) -> + if is_elidable_with_module_type_u expr then ModuleType expr + else Functor (ModuleType (u_module_type_expr env id expr)) | Alias p -> Alias (module_path env p) and module_type : Env.t -> ModuleType.t -> ModuleType.t = @@ -413,14 +414,16 @@ and include_ : Env.t -> Include.t -> Include.t * Env.t = match let open Odoc_utils.ResultMonad in match decl with - | Functor p -> + | Functor (Path p) -> Tools.expansion_of_module_path env ~strengthen:true p >>= fun exp -> Tools.assert_functor exp + | Functor (ModuleType mty) -> + Tools.signature_of_u_module_type_expr env mty ~allow_functor:true | Alias p -> Tools.expansion_of_module_path env ~strengthen:true p >>= fun exp -> Tools.assert_not_functor exp - | ModuleType mty -> - Tools.signature_of_u_module_type_expr env mty + | ModuleType mty -> + Tools.signature_of_u_module_type_expr env mty ~allow_functor:false with | Error e -> Errors.report ~what:(`Include decl) ~tools_error:e `Expand; @@ -646,7 +649,9 @@ and module_type_map_subs env id cexpr subs = match find_parent cexpr with | None -> None | Some parent -> ( - match Tools.signature_of_u_module_type_expr env cexpr with + match + Tools.signature_of_u_module_type_expr env cexpr ~allow_functor:false + with | Error e -> Errors.report ~what:(`Module_type id) ~tools_error:e `Lookup; None diff --git a/src/xref2/component.ml b/src/xref2/component.ml index 4c61e12250..e26874737d 100644 --- a/src/xref2/component.ml +++ b/src/xref2/component.ml @@ -364,7 +364,11 @@ end = Open and Include : sig - type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr | Functor of Cpath.module_ + type functor' = Path of Cpath.module_ | ModuleType of ModuleType.U.expr + type decl = + | Alias of Cpath.module_ + | ModuleType of ModuleType.U.expr + | Functor of functor' type t = { parent : Odoc_model.Paths.Identifier.Signature.t; @@ -924,7 +928,9 @@ module Fmt = struct let open Include in function | Alias p -> Format.fprintf ppf "%a" (module_path c) p - | Functor p -> Format.fprintf ppf "functor %a" (module_path c) p + | Functor (Path p) -> Format.fprintf ppf "functor %a" (module_path c) p + | Functor (ModuleType mt) -> + Format.fprintf ppf "functor %a" (u_module_type_expr c) mt | ModuleType mt -> Format.fprintf ppf "%a" (u_module_type_expr c) mt and value c ppf v = @@ -2411,7 +2417,9 @@ module Of_Lang = struct and include_decl ident_map m = match m with | Odoc_model.Lang.Include.Alias p -> Include.Alias (module_path ident_map p) - | Functor p -> Functor (module_path ident_map p) + | Functor (Path p) -> Functor (Path (module_path ident_map p)) + | Functor (ModuleType s) -> + Functor (ModuleType (u_module_type_expr ident_map s)) | ModuleType s -> ModuleType (u_module_type_expr ident_map s) and simple_expansion ident_map diff --git a/src/xref2/component.mli b/src/xref2/component.mli index 19c7c10a5f..8a3a92a03d 100644 --- a/src/xref2/component.mli +++ b/src/xref2/component.mli @@ -336,7 +336,11 @@ and Open : sig end and Include : sig - type decl = Alias of Cpath.module_ | ModuleType of ModuleType.U.expr | Functor of Cpath.module_ + type functor' = Path of Cpath.module_ | ModuleType of ModuleType.U.expr + type decl = + | Alias of Cpath.module_ + | ModuleType of ModuleType.U.expr + | Functor of functor' type t = { parent : Odoc_model.Paths.Identifier.Signature.t; diff --git a/src/xref2/lang_of.ml b/src/xref2/lang_of.ml index cea2df341e..88fff40ea4 100644 --- a/src/xref2/lang_of.ml +++ b/src/xref2/lang_of.ml @@ -651,7 +651,10 @@ and include_decl : (* Don't start shadowing within any signatures *) match d with | Alias p -> Alias (Path.module_ map p) - | Functor p -> Functor (Path.module_ map p) + | Functor (Path p) -> Functor (Path (Path.module_ map p)) + | Functor (ModuleType mty) -> + let include_parent = Identifier.fresh_include_parent identifier in + Functor (ModuleType (u_module_type_expr map include_parent mty)) | ModuleType mty -> let include_parent = Identifier.fresh_include_parent identifier in ModuleType (u_module_type_expr map include_parent mty) diff --git a/src/xref2/link.ml b/src/xref2/link.ml index 4ac1aada2f..1b38fa8c0a 100644 --- a/src/xref2/link.ml +++ b/src/xref2/link.ml @@ -707,8 +707,9 @@ and include_decl : Env.t -> Id.Signature.t -> Include.decl -> Include.decl = match decl with | ModuleType expr when is_elidable_with_module_type_u expr -> ModuleType expr | ModuleType expr -> ModuleType (u_module_type_expr env id expr) - (* TODO dedup *) - | Functor p -> Functor (module_path env p) + | Functor (Path p) -> Functor (Path (module_path env p)) + | Functor (ModuleType expr) -> + Functor (ModuleType (u_module_type_expr env id expr)) | Alias p -> Alias (module_path env p) and module_type : Env.t -> ModuleType.t -> ModuleType.t = @@ -900,7 +901,9 @@ and u_module_type_expr : | Path p -> Path (module_type_path env p) | With (subs, expr) as unresolved -> ( let cexpr = Component.Of_Lang.(u_module_type_expr (empty ()) expr) in - match Tools.signature_of_u_module_type_expr env cexpr with + match + Tools.signature_of_u_module_type_expr env cexpr ~allow_functor:false + with | Ok sg -> With (handle_fragments env id sg subs, u_module_type_expr env id expr) | Error e -> @@ -947,7 +950,9 @@ and module_type_expr : Path { p_path; p_expansion = do_expn p_expansion (Some p_path) } | With { w_substitutions; w_expansion; w_expr } as unresolved -> ( let cexpr = Component.Of_Lang.(u_module_type_expr (empty ()) w_expr) in - match Tools.signature_of_u_module_type_expr env cexpr with + match + Tools.signature_of_u_module_type_expr env cexpr ~allow_functor:false + with | Ok sg -> With { diff --git a/src/xref2/subst.ml b/src/xref2/subst.ml index 9e7a305257..64a16662ec 100644 --- a/src/xref2/subst.ml +++ b/src/xref2/subst.ml @@ -759,7 +759,8 @@ and module_decl s t = and include_decl s t = match t with | Include.Alias p -> Include.Alias (module_path s p) - | Functor p -> Functor (module_path s p) + | Functor (Path p) -> Functor (Path (module_path s p)) + | Functor (ModuleType t) -> ModuleType (u_module_type_expr s t) | ModuleType t -> ModuleType (u_module_type_expr s t) and module_ s t = diff --git a/src/xref2/tools.ml b/src/xref2/tools.ml index 12ad115ee8..ca8e641db9 100644 --- a/src/xref2/tools.ml +++ b/src/xref2/tools.ml @@ -1627,22 +1627,28 @@ and signature_of_module_type_of : and signature_of_u_module_type_expr : Env.t -> Component.ModuleType.U.expr -> + allow_functor:bool -> (Component.Signature.t, expansion_of_module_error) result = - fun env m -> + fun env m ~allow_functor -> match m with | Component.ModuleType.U.Path p -> ( match resolve_module_type env p with - | Ok (_, mt) -> expansion_of_module_type env mt >>= assert_not_functor + | Ok (_, mt) -> ( + expansion_of_module_type env mt + >>= + match allow_functor with + | true -> assert_functor + | false -> assert_not_functor) | Error e -> Error (`UnresolvedPath (`ModuleType (p, e)))) | Signature s -> Ok s | With (subs, s) -> - signature_of_u_module_type_expr env s >>= fun sg -> + signature_of_u_module_type_expr env s ~allow_functor >>= fun sg -> let subs = unresolve_subs subs in handle_signature_with_subs env sg subs | TypeOf (desc, original_path) -> signature_of_module_type_of env desc ~original_path >>= assert_not_functor | Strengthen (expr, path, _aliasable) -> - signature_of_u_module_type_expr env expr >>= fun sg -> + signature_of_u_module_type_expr env expr ~allow_functor >>= fun sg -> Ok (Strengthen.signature path sg) and expansion_of_simple_expansion : @@ -1673,7 +1679,8 @@ and expansion_of_module_type_expr : | Component.ModuleType.With { w_expansion = Some e; _ } -> Ok (expansion_of_simple_expansion e) | Component.ModuleType.With { w_substitutions; w_expr; _ } -> - signature_of_u_module_type_expr env w_expr >>= fun sg -> + signature_of_u_module_type_expr env w_expr ~allow_functor:false + >>= fun sg -> let subs = unresolve_subs w_substitutions in handle_signature_with_subs env sg subs >>= fun sg -> Ok (Signature sg) | Component.ModuleType.Functor (arg, expr) -> Ok (Functor (arg, expr)) @@ -1687,7 +1694,8 @@ and expansion_of_module_type_expr : in expansion_of_module_path env ~strengthen p | Component.ModuleType.Strengthen { s_expr; s_path; _ } -> - signature_of_u_module_type_expr env s_expr >>= fun sg -> + signature_of_u_module_type_expr env s_expr ~allow_functor:false + >>= fun sg -> let sg = Strengthen.signature s_path sg in Ok (Signature sg) @@ -1818,11 +1826,12 @@ and fragmap : expansion_of_module_path env ~strengthen:true p >>= assert_not_functor >>= fun sg -> fragmap env subst sg >>= fun sg -> Ok (ModuleType (Signature sg)) - | Functor p -> + | Functor (Path p) -> expansion_of_module_path env ~strengthen:true p >>= assert_functor >>= fun sg -> fragmap env subst sg >>= fun sg -> Ok (ModuleType (Signature sg)) - | ModuleType mty' -> Ok (ModuleType (With ([ subst ], mty'))) + | Functor (ModuleType mty') | ModuleType mty' -> + Ok (ModuleType (With ([ subst ], mty'))) in let map_module m new_subst = let open Component.Module in diff --git a/src/xref2/tools.mli b/src/xref2/tools.mli index 7b3fb06647..b381c1534e 100644 --- a/src/xref2/tools.mli +++ b/src/xref2/tools.mli @@ -242,6 +242,7 @@ val expansion_of_module_type_expr : val signature_of_u_module_type_expr : Env.t -> Component.ModuleType.U.expr -> + allow_functor:bool -> (Component.Signature.t, expansion_of_module_error) result (** The following functions are use for the resolution of {{!type:Odoc_model.Paths.Fragment.t}Fragments} Whilst resolving fragments it diff --git a/test/generators/cases/oxcaml.mli b/test/generators/cases/oxcaml.mli index f2c0ae266a..0557c84fe3 100644 --- a/test/generators/cases/oxcaml.mli +++ b/test/generators/cases/oxcaml.mli @@ -284,6 +284,8 @@ end (** {1 Include functor on signatures} *) module No_include_functor : sig +(** Module without any [include functor] features, this is how things are done + in plain OCaml at the moment. *) module Make (T : sig type t end) : sig type included end module T : sig type t @@ -294,7 +296,15 @@ module No_include_functor : sig end module Include_functor : sig +(** Module which defines a functor and includes it via [module type of] *) module Make (T : sig type t end) : sig type included end type t include functor module type of Make end + +module Include_functor_named_type : sig +(** This is a Module where the type is named and then included. *) + module type Make = (_ : sig type t end) -> sig type included end + type t + include functor Make +end diff --git a/test/generators/cases/oxcaml_impl.ml b/test/generators/cases/oxcaml_impl.ml index cdff2e51cb..caffeb8a98 100644 --- a/test/generators/cases/oxcaml_impl.ml +++ b/test/generators/cases/oxcaml_impl.ml @@ -12,6 +12,8 @@ end (** {1 Include functor on structures} *) module No_include_functor = struct +(** This module shows how to achieve the effect without [include functor], + with an intermediate module [T]. *) module Make (T : sig type t end) = struct type included end module T = struct type t @@ -22,6 +24,7 @@ module No_include_functor = struct end module Include_functor = struct +(** This module demonstratest the [include functor] functionality *) module Make (T : sig type t end) = struct type included end type t include functor Make diff --git a/test/generators/html/Oxcaml-Include_functor-Make.html b/test/generators/html/Oxcaml-Include_functor-Make.html index 2cc91dce29..1c5465d38c 100644 --- a/test/generators/html/Oxcaml-Include_functor-Make.html +++ b/test/generators/html/Oxcaml-Include_functor-Make.html @@ -15,6 +15,9 @@

    Module Include_functor.Make

    +

    Module which defines a functor and includes it via + module type of +

    +
    +

    Module which defines a functor and includes it via + module type of +

    +
    diff --git a/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html b/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html new file mode 100644 index 0000000000..e9fff279f8 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html @@ -0,0 +1,33 @@ + + + _ (Oxcaml.Include_functor_named_type.Make._) + + + + + + + + +
    +

    Parameter Make._

    +
    +
    +
    +
    + + type t +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make.html b/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make.html new file mode 100644 index 0000000000..4e0c82a4b9 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor_named_type-module-type-Make.html @@ -0,0 +1,58 @@ + + + Make (Oxcaml.Include_functor_named_type.Make) + + + + + + + + +
    +

    Module type Include_functor_named_type.Make +

    This is a Module where the type is named and then included.

    +
    +
    + +
    +
    +

    Parameters +

    +
    +
    + + module + + _ + + + : sig ... + end + + +
    +
    +

    Signature

    +
    +
    + + type included +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml-Include_functor_named_type.html b/test/generators/html/Oxcaml-Include_functor_named_type.html new file mode 100644 index 0000000000..5cb1f9af18 --- /dev/null +++ b/test/generators/html/Oxcaml-Include_functor_named_type.html @@ -0,0 +1,74 @@ + + + + Include_functor_named_type (Oxcaml.Include_functor_named_type) + + + + + + + + +
    +

    Module Oxcaml.Include_functor_named_type +

    +
    +
    +
    +
    + + + module + type + Make + + + = functor + ( + _ + : sig ... + end) + -> + sig ... + end + + +
    +
    +

    This is a Module where the type is named and then included.

    +
    +
    +
    +
    + + type t +
    +
    +
    +
    + + + include functor + + Make + + + + +
    +
    + + type included +
    +
    +
    +
    +
    + + diff --git a/test/generators/html/Oxcaml-No_include_functor-Make.html b/test/generators/html/Oxcaml-No_include_functor-Make.html index aff06ab0bd..d8e38c5788 100644 --- a/test/generators/html/Oxcaml-No_include_functor-Make.html +++ b/test/generators/html/Oxcaml-No_include_functor-Make.html @@ -16,6 +16,9 @@

    Module No_include_functor.Make

    +

    Module without any include functor features, this + is how things are done in plain OCaml at the moment. +

    +
    +

    Module without any include functor features, this + is how things are done in plain OCaml at the moment. +

    +
    diff --git a/test/generators/html/Oxcaml.html b/test/generators/html/Oxcaml.html index f677107377..0a0cd9d6fb 100644 --- a/test/generators/html/Oxcaml.html +++ b/test/generators/html/Oxcaml.html @@ -1216,6 +1216,21 @@

    +
    +
    + + + module + + Include_functor_named_type + + + : sig ... + end + + +
    +
    diff --git a/test/generators/html/Oxcaml_impl-Include_functor-Make.html b/test/generators/html/Oxcaml_impl-Include_functor-Make.html index 63fd3d57ca..a457eade36 100644 --- a/test/generators/html/Oxcaml_impl-Include_functor-Make.html +++ b/test/generators/html/Oxcaml_impl-Include_functor-Make.html @@ -16,6 +16,9 @@

    Module Include_functor.Make

    +

    This module demonstratest the include functor + functionality +

    +
    +

    This module demonstratest the include functor + functionality +

    +
    diff --git a/test/generators/html/Oxcaml_impl-No_include_functor-Make.html b/test/generators/html/Oxcaml_impl-No_include_functor-Make.html index f27582db18..69ea651872 100644 --- a/test/generators/html/Oxcaml_impl-No_include_functor-Make.html +++ b/test/generators/html/Oxcaml_impl-No_include_functor-Make.html @@ -16,6 +16,10 @@

    Module No_include_functor.Make

    +

    This module shows how to achieve the effect without + include functor, with an intermediate module T + . +

    +
    +

    This module shows how to achieve the effect without + include functor, with an intermediate module + T. +

    +
    diff --git a/test/generators/html/oxcaml.targets b/test/generators/html/oxcaml.targets index 09e7279c6d..37a8e467cf 100644 --- a/test/generators/html/oxcaml.targets +++ b/test/generators/html/oxcaml.targets @@ -10,3 +10,6 @@ Oxcaml-No_include_functor-T.html Oxcaml-Include_functor.html Oxcaml-Include_functor-Make.html Oxcaml-Include_functor-Make-argument-1-T.html +Oxcaml-Include_functor_named_type.html +Oxcaml-Include_functor_named_type-module-type-Make.html +Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html diff --git a/test/generators/latex/Oxcaml.tex b/test/generators/latex/Oxcaml.tex index 1c35f41037..3a47f2cd64 100644 --- a/test/generators/latex/Oxcaml.tex +++ b/test/generators/latex/Oxcaml.tex @@ -241,7 +241,8 @@ \subsubsection{Modalities on module declarations\label{Oxcaml--modalities-on-mod \ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}\ocamlinlinecode{contended} modality applied to all definitions in the module, except the ones which have already specified this axis.\end{ocamlindent}% \medbreak \subsection{Include functor on signatures\label{Oxcaml--include-functor-on-signatures}}% -\label{Oxcaml--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\begin{ocamlindent}Module without any \ocamlinlinecode{include functor} features, this is how things are done in plain OCaml at the moment.\end{ocamlindent}% +\medbreak \label{Oxcaml-No_include_functor--module-T}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-No_include_functor-T]{\ocamlinlinecode{T}}}\label{Oxcaml-No_include_functor-T}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-No_include_functor-T--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ @@ -249,10 +250,24 @@ \subsection{Include functor on signatures\label{Oxcaml--include-functor-on-signa \ocamltag{keyword}{include} \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}\label{Oxcaml-No_include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included = \hyperref[Oxcaml-No_include_functor-Make--type-included]{\ocamlinlinecode{Make(T).\allowbreak{}included}}}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ -\label{Oxcaml--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\begin{ocamlindent}Module which defines a functor and includes it via \ocamlinlinecode{module type of}\end{ocamlindent}% +\medbreak \label{Oxcaml-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ \ocamltag{keyword}{include functor} \hyperref[Oxcaml-Include_functor-Make]{\ocamlinlinecode{Make}}\label{Oxcaml-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\label{Oxcaml--module-Include_functor_named_type}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor_named_type]{\ocamlinlinecode{Include\_\allowbreak{}functor\_\allowbreak{}named\_\allowbreak{}type}}}\label{Oxcaml-Include_functor_named_type}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor_named_type--module-type-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[Oxcaml-Include_functor_named_type-module-type-Make]{\ocamlinlinecode{Make}}}\label{Oxcaml-Include_functor_named_type-module-type-Make}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\subsubsection{Parameters\label{Oxcaml-Include_functor_named_type-module-type-Make--parameters_3}}% +\label{Oxcaml-Include_functor_named_type-module-type-Make--argument-1-_}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_]{\ocamlinlinecode{\_\allowbreak{}}}}\label{Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ +\subsubsection{Signature\label{Oxcaml-Include_functor_named_type-module-type-Make--signature_3}}% +\label{Oxcaml-Include_functor_named_type-module-type-Make--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\begin{ocamlindent}This is a Module where the type is named and then included.\end{ocamlindent}% +\medbreak +\label{Oxcaml-Include_functor_named_type--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ +\ocamltag{keyword}{include functor} \hyperref[Oxcaml-Include_functor_named_type-module-type-Make]{\ocamlinlinecode{Make}}\label{Oxcaml-Include_functor_named_type--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ +\end{ocamlindent}% +\ocamlcodefragment{\ocamltag{keyword}{end}}\\ \input{Oxcaml.M1.tex} diff --git a/test/generators/latex/Oxcaml_impl.tex b/test/generators/latex/Oxcaml_impl.tex index 4ed3e70565..36e9e66238 100644 --- a/test/generators/latex/Oxcaml_impl.tex +++ b/test/generators/latex/Oxcaml_impl.tex @@ -7,7 +7,8 @@ \section{Module \ocamlinlinecode{Oxcaml\_\allowbreak{}impl}}\label{Oxcaml_impl}% \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ \subsection{Include functor on structures\label{Oxcaml_impl--include-functor-on-structures}}% -\label{Oxcaml_impl--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml_impl-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml_impl--module-No_include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor]{\ocamlinlinecode{No\_\allowbreak{}include\_\allowbreak{}functor}}}\label{Oxcaml_impl-No_include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-No_include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-No_include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\begin{ocamlindent}This module shows how to achieve the effect without \ocamlinlinecode{include functor}, with an intermediate module \ocamlinlinecode{T}.\end{ocamlindent}% +\medbreak \label{Oxcaml_impl-No_include_functor--module-T}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-No_include_functor-T]{\ocamlinlinecode{T}}}\label{Oxcaml_impl-No_include_functor-T}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-No_include_functor-T--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ @@ -15,7 +16,8 @@ \subsection{Include functor on structures\label{Oxcaml_impl--include-functor-on- \ocamltag{keyword}{include} \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}\label{Oxcaml_impl-No_include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included = \hyperref[Oxcaml_impl-No_include_functor-Make--type-included]{\ocamlinlinecode{Make(T).\allowbreak{}included}}}\\ \end{ocamlindent}% \ocamlcodefragment{\ocamltag{keyword}{end}}\\ -\label{Oxcaml_impl--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml_impl-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\ +\label{Oxcaml_impl--module-Include_functor}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor]{\ocamlinlinecode{Include\_\allowbreak{}functor}}}\label{Oxcaml_impl-Include_functor}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{Oxcaml_impl-Include_functor--module-Make}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}}\ocamlcodefragment{ (\hyperref[Oxcaml_impl-Include_functor-Make-argument-1-T]{\ocamlinlinecode{T}} : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\begin{ocamlindent}This module demonstratest the \ocamlinlinecode{include functor} functionality\end{ocamlindent}% +\medbreak \label{Oxcaml_impl-Include_functor--type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\ \ocamltag{keyword}{include functor} \hyperref[Oxcaml_impl-Include_functor-Make]{\ocamlinlinecode{Make}}\label{Oxcaml_impl-Include_functor--type-included}\ocamlcodefragment{\ocamltag{keyword}{type} included}\\ \end{ocamlindent}% diff --git a/test/generators/link.dune.inc b/test/generators/link.dune.inc index 43e8390e8f..34be12a35e 100644 --- a/test/generators/link.dune.inc +++ b/test/generators/link.dune.inc @@ -11958,7 +11958,10 @@ Oxcaml-No_include_functor-T.html.gen Oxcaml-Include_functor.html.gen Oxcaml-Include_functor-Make.html.gen - Oxcaml-Include_functor-Make-argument-1-T.html.gen) + Oxcaml-Include_functor-Make-argument-1-T.html.gen + Oxcaml-Include_functor_named_type.html.gen + Oxcaml-Include_functor_named_type-module-type-Make.html.gen + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html.gen) (package odoc) (action (run @@ -12053,6 +12056,30 @@ (diff Oxcaml-Include_functor-Make-argument-1-T.html Oxcaml-Include_functor-Make-argument-1-T.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type.html + Oxcaml-Include_functor_named_type.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type-module-type-Make.html + Oxcaml-Include_functor_named_type-module-type-Make.html.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.html.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12122,7 +12149,8 @@ Oxcaml.No_include_functor.Make.3o.gen Oxcaml.No_include_functor.T.3o.gen Oxcaml.Include_functor.3o.gen - Oxcaml.Include_functor.Make.3o.gen) + Oxcaml.Include_functor.Make.3o.gen + Oxcaml.Include_functor_named_type.3o.gen) (package odoc) (action (run odoc man-generate -o . --extra-suffix gen %{dep:../oxcaml.odocl})) @@ -12182,6 +12210,14 @@ (package odoc) (action (diff Oxcaml.Include_functor.Make.3o Oxcaml.Include_functor.Make.3o.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml.Include_functor_named_type.3o + Oxcaml.Include_functor_named_type.3o.gen)) (enabled_if %{ocaml-config:ox}))) (subdir @@ -12216,7 +12252,10 @@ Oxcaml-No_include_functor-T.md.gen Oxcaml-Include_functor.md.gen Oxcaml-Include_functor-Make.md.gen - Oxcaml-Include_functor-Make-argument-1-T.md.gen) + Oxcaml-Include_functor-Make-argument-1-T.md.gen + Oxcaml-Include_functor_named_type.md.gen + Oxcaml-Include_functor_named_type-module-type-Make.md.gen + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md.gen) (package odoc) (action (run @@ -12305,6 +12344,30 @@ (diff Oxcaml-Include_functor-Make-argument-1-T.md Oxcaml-Include_functor-Make-argument-1-T.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type.md + Oxcaml-Include_functor_named_type.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type-module-type-Make.md + Oxcaml-Include_functor_named_type-module-type-Make.md.gen)) + (enabled_if %{ocaml-config:ox})) + (rule + (alias runtest) + (package odoc) + (action + (diff + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md + Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md.gen)) (enabled_if %{ocaml-config:ox}))) (subdir diff --git a/test/generators/man/Oxcaml.3o b/test/generators/man/Oxcaml.3o index 3b695a1fdf..a20223f479 100644 --- a/test/generators/man/Oxcaml.3o +++ b/test/generators/man/Oxcaml.3o @@ -689,3 +689,5 @@ contended modality applied to all definitions in the module, except the ones whi \f[CB]module\fR No_include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR .sp \f[CB]module\fR Include_functor : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.sp +\f[CB]module\fR Include_functor_named_type : \f[CB]sig\fR \.\.\. \f[CB]end\fR diff --git a/test/generators/man/Oxcaml.Include_functor.3o b/test/generators/man/Oxcaml.Include_functor.3o index 91667a49b7..a0776f720c 100644 --- a/test/generators/man/Oxcaml.Include_functor.3o +++ b/test/generators/man/Oxcaml.Include_functor.3o @@ -12,6 +12,11 @@ Oxcaml\.Include_functor .sp .nf \f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.fi +.br +.ti +2 +Module which defines a functor and includes it via module type of +.nf .sp \f[CB]type\fR t .sp diff --git a/test/generators/man/Oxcaml.Include_functor.Make.3o b/test/generators/man/Oxcaml.Include_functor.Make.3o index 0a52767dec..a5217b11b7 100644 --- a/test/generators/man/Oxcaml.Include_functor.Make.3o +++ b/test/generators/man/Oxcaml.Include_functor.Make.3o @@ -8,6 +8,9 @@ Oxcaml\.Include_functor\.Make \fBModule Include_functor\.Make\fR .in .sp +.fi +Module which defines a functor and includes it via module type of +.nf .SH Documentation .sp .nf diff --git a/test/generators/man/Oxcaml.Include_functor_named_type.3o b/test/generators/man/Oxcaml.Include_functor_named_type.3o new file mode 100644 index 0000000000..f8ef1c2b17 --- /dev/null +++ b/test/generators/man/Oxcaml.Include_functor_named_type.3o @@ -0,0 +1,45 @@ + +.TH Include_functor_named_type 3 "" "Odoc" "OCaml Library" +.SH Name +Oxcaml\.Include_functor_named_type +.SH Synopsis +.sp +.in 2 +\fBModule Oxcaml\.Include_functor_named_type\fR +.in +.sp +.SH Documentation +.sp +.nf +\f[CB]module\fR \f[CB]type\fR Make = \f[CB]sig\fR +.br +.ti +2 +.sp +.ti +2 +\fB1\.1 Parameters\fR +.sp +.ti +2 +\f[CB]module\fR _ : \f[CB]sig\fR +.br +.ti +4 +\f[CB]type\fR t +.br +.ti +2 +\f[CB]end\fR +.sp +.ti +2 +\fB1\.2 Signature\fR +.sp +.ti +2 +\f[CB]type\fR included +.br +\f[CB]end\fR +.fi +.br +.ti +2 +This is a Module where the type is named and then included\. +.nf +.sp +\f[CB]type\fR t +.sp +\f[CB]type\fR included diff --git a/test/generators/man/Oxcaml.No_include_functor.3o b/test/generators/man/Oxcaml.No_include_functor.3o index b2604f7274..d9b130cc57 100644 --- a/test/generators/man/Oxcaml.No_include_functor.3o +++ b/test/generators/man/Oxcaml.No_include_functor.3o @@ -12,6 +12,11 @@ Oxcaml\.No_include_functor .sp .nf \f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.fi +.br +.ti +2 +Module without any include functor features, this is how things are done in plain OCaml at the moment\. +.nf .sp \f[CB]module\fR T : \f[CB]sig\fR \.\.\. \f[CB]end\fR .sp diff --git a/test/generators/man/Oxcaml.No_include_functor.Make.3o b/test/generators/man/Oxcaml.No_include_functor.Make.3o index 094a4e7ce1..6438bce203 100644 --- a/test/generators/man/Oxcaml.No_include_functor.Make.3o +++ b/test/generators/man/Oxcaml.No_include_functor.Make.3o @@ -8,6 +8,9 @@ Oxcaml\.No_include_functor\.Make \fBModule No_include_functor\.Make\fR .in .sp +.fi +Module without any include functor features, this is how things are done in plain OCaml at the moment\. +.nf .SH Documentation .sp .nf diff --git a/test/generators/man/Oxcaml_impl.Include_functor.3o b/test/generators/man/Oxcaml_impl.Include_functor.3o index 13ecc3dc04..ccdb31fa51 100644 --- a/test/generators/man/Oxcaml_impl.Include_functor.3o +++ b/test/generators/man/Oxcaml_impl.Include_functor.3o @@ -12,6 +12,11 @@ Oxcaml_impl\.Include_functor .sp .nf \f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.fi +.br +.ti +2 +This module demonstratest the include functor functionality +.nf .sp \f[CB]type\fR t .sp diff --git a/test/generators/man/Oxcaml_impl.Include_functor.Make.3o b/test/generators/man/Oxcaml_impl.Include_functor.Make.3o index c65b57ad93..de73e9d81e 100644 --- a/test/generators/man/Oxcaml_impl.Include_functor.Make.3o +++ b/test/generators/man/Oxcaml_impl.Include_functor.Make.3o @@ -8,6 +8,9 @@ Oxcaml_impl\.Include_functor\.Make \fBModule Include_functor\.Make\fR .in .sp +.fi +This module demonstratest the include functor functionality +.nf .SH Documentation .sp .nf diff --git a/test/generators/man/Oxcaml_impl.No_include_functor.3o b/test/generators/man/Oxcaml_impl.No_include_functor.3o index f5f9d6b80b..0c1058d355 100644 --- a/test/generators/man/Oxcaml_impl.No_include_functor.3o +++ b/test/generators/man/Oxcaml_impl.No_include_functor.3o @@ -12,6 +12,11 @@ Oxcaml_impl\.No_include_functor .sp .nf \f[CB]module\fR Make (T : \f[CB]sig\fR \.\.\. \f[CB]end\fR) : \f[CB]sig\fR \.\.\. \f[CB]end\fR +.fi +.br +.ti +2 +This module shows how to achieve the effect without include functor, with an intermediate module T\. +.nf .sp \f[CB]module\fR T : \f[CB]sig\fR \.\.\. \f[CB]end\fR .sp diff --git a/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o b/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o index 117a283d5c..283ddc0e27 100644 --- a/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o +++ b/test/generators/man/Oxcaml_impl.No_include_functor.Make.3o @@ -8,6 +8,9 @@ Oxcaml_impl\.No_include_functor\.Make \fBModule No_include_functor\.Make\fR .in .sp +.fi +This module shows how to achieve the effect without include functor, with an intermediate module T\. +.nf .SH Documentation .sp .nf diff --git a/test/generators/man/oxcaml.targets b/test/generators/man/oxcaml.targets index 2686a0c521..e45f9b79eb 100644 --- a/test/generators/man/oxcaml.targets +++ b/test/generators/man/oxcaml.targets @@ -7,3 +7,4 @@ Oxcaml.No_include_functor.Make.3o Oxcaml.No_include_functor.T.3o Oxcaml.Include_functor.3o Oxcaml.Include_functor.Make.3o +Oxcaml.Include_functor_named_type.3o diff --git a/test/generators/markdown/Oxcaml-Include_functor-Make.md b/test/generators/markdown/Oxcaml-Include_functor-Make.md index 717336f028..a131081dc7 100644 --- a/test/generators/markdown/Oxcaml-Include_functor-Make.md +++ b/test/generators/markdown/Oxcaml-Include_functor-Make.md @@ -1,6 +1,8 @@ # Module `Include_functor.Make` +Module which defines a functor and includes it via `module type of` + ## Parameters diff --git a/test/generators/markdown/Oxcaml-Include_functor.md b/test/generators/markdown/Oxcaml-Include_functor.md index 77b7d949e4..e54338a324 100644 --- a/test/generators/markdown/Oxcaml-Include_functor.md +++ b/test/generators/markdown/Oxcaml-Include_functor.md @@ -4,6 +4,8 @@ ```ocaml module Make (T : sig ... end) : sig ... end ``` +Module which defines a functor and includes it via `module type of` + ```ocaml type t ``` diff --git a/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md b/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md new file mode 100644 index 0000000000..4f3631ee75 --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md @@ -0,0 +1,6 @@ + +# Parameter `Make._` + +```ocaml +type t +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make.md b/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make.md new file mode 100644 index 0000000000..2538468067 --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor_named_type-module-type-Make.md @@ -0,0 +1,17 @@ + +# Module type `Include_functor_named_type.Make` + +This is a Module where the type is named and then included. + + +## Parameters + +```ocaml +module _ : sig ... end +``` + +## Signature + +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-Include_functor_named_type.md b/test/generators/markdown/Oxcaml-Include_functor_named_type.md new file mode 100644 index 0000000000..7aa04d1ac8 --- /dev/null +++ b/test/generators/markdown/Oxcaml-Include_functor_named_type.md @@ -0,0 +1,14 @@ + +# Module `Oxcaml.Include_functor_named_type` + +```ocaml +module type Make = functor (_ : sig ... end) -> sig ... end +``` +This is a Module where the type is named and then included. + +```ocaml +type t +``` +```ocaml +type included +``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml-No_include_functor-Make.md b/test/generators/markdown/Oxcaml-No_include_functor-Make.md index 552520f632..f6909af03f 100644 --- a/test/generators/markdown/Oxcaml-No_include_functor-Make.md +++ b/test/generators/markdown/Oxcaml-No_include_functor-Make.md @@ -1,6 +1,8 @@ # Module `No_include_functor.Make` +Module without any `include functor` features, this is how things are done in plain OCaml at the moment. + ## Parameters diff --git a/test/generators/markdown/Oxcaml-No_include_functor.md b/test/generators/markdown/Oxcaml-No_include_functor.md index 3f948350f1..c6228a22f0 100644 --- a/test/generators/markdown/Oxcaml-No_include_functor.md +++ b/test/generators/markdown/Oxcaml-No_include_functor.md @@ -4,6 +4,8 @@ ```ocaml module Make (T : sig ... end) : sig ... end ``` +Module without any `include functor` features, this is how things are done in plain OCaml at the moment. + ```ocaml module T : sig ... end ``` diff --git a/test/generators/markdown/Oxcaml.md b/test/generators/markdown/Oxcaml.md index a722b5c1b0..ef5b4fbcc7 100644 --- a/test/generators/markdown/Oxcaml.md +++ b/test/generators/markdown/Oxcaml.md @@ -354,4 +354,7 @@ module No_include_functor : sig ... end ``` ```ocaml module Include_functor : sig ... end +``` +```ocaml +module Include_functor_named_type : sig ... end ``` \ No newline at end of file diff --git a/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md b/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md index 717336f028..6bb4b93f08 100644 --- a/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md +++ b/test/generators/markdown/Oxcaml_impl-Include_functor-Make.md @@ -1,6 +1,8 @@ # Module `Include_functor.Make` +This module demonstratest the `include functor` functionality + ## Parameters diff --git a/test/generators/markdown/Oxcaml_impl-Include_functor.md b/test/generators/markdown/Oxcaml_impl-Include_functor.md index 854486cfe2..0478033a7b 100644 --- a/test/generators/markdown/Oxcaml_impl-Include_functor.md +++ b/test/generators/markdown/Oxcaml_impl-Include_functor.md @@ -4,6 +4,8 @@ ```ocaml module Make (T : sig ... end) : sig ... end ``` +This module demonstratest the `include functor` functionality + ```ocaml type t ``` diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md index 552520f632..81cbc7cb82 100644 --- a/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor-Make.md @@ -1,6 +1,8 @@ # Module `No_include_functor.Make` +This module shows how to achieve the effect without `include functor`, with an intermediate module `T`. + ## Parameters diff --git a/test/generators/markdown/Oxcaml_impl-No_include_functor.md b/test/generators/markdown/Oxcaml_impl-No_include_functor.md index 1ad27ff002..10f6b8c8ab 100644 --- a/test/generators/markdown/Oxcaml_impl-No_include_functor.md +++ b/test/generators/markdown/Oxcaml_impl-No_include_functor.md @@ -4,6 +4,8 @@ ```ocaml module Make (T : sig ... end) : sig ... end ``` +This module shows how to achieve the effect without `include functor`, with an intermediate module `T`. + ```ocaml module T : sig ... end ``` diff --git a/test/generators/markdown/oxcaml.targets b/test/generators/markdown/oxcaml.targets index 1fa2a3c0dd..4e6a13cce2 100644 --- a/test/generators/markdown/oxcaml.targets +++ b/test/generators/markdown/oxcaml.targets @@ -10,3 +10,6 @@ Oxcaml-No_include_functor-T.md Oxcaml-Include_functor.md Oxcaml-Include_functor-Make.md Oxcaml-Include_functor-Make-argument-1-T.md +Oxcaml-Include_functor_named_type.md +Oxcaml-Include_functor_named_type-module-type-Make.md +Oxcaml-Include_functor_named_type-module-type-Make-argument-1-_.md From a6c9652a20f67e0511de068b8ea8a84aa6269a1c Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Tue, 30 Jun 2026 14:36:18 +0200 Subject: [PATCH 7/7] Add changelog entry --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 551d12f499..423f94a2e7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ - Support for OxCaml zero alloc definitions (@Leonidas-from-XIV, #1422, #1444) - Remove requirement for ppx_expect in tests (@jonludlam, #1445) - Support for OxCaml modalities (@art-w, #1420) +- Display items included via `include functor` as included via the functor + (@Leonidas-from-XIV, #1452) # 3.2.1