summaryrefslogtreecommitdiff
path: root/ocamldoc
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2022-06-30 18:11:22 +0200
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2022-06-30 18:11:23 +0200
commit50756a52b5809e3065a8a1b96da62161ad085e79 (patch)
treea47f1f591fb9b8861d7107cb743f173b40a23739 /ocamldoc
parent0d8a7664194c29086844cc01b80d3dccfec4da94 (diff)
downloadocaml-50756a52b5809e3065a8a1b96da62161ad085e79.tar.gz
Provide an interface for ocamldoc's odoc_value module
Diffstat (limited to 'ocamldoc')
-rw-r--r--ocamldoc/.depend37
-rw-r--r--ocamldoc/Makefile2
-rw-r--r--ocamldoc/odoc_value.ml16
-rw-r--r--ocamldoc/odoc_value.mli64
4 files changed, 87 insertions, 32 deletions
diff --git a/ocamldoc/.depend b/ocamldoc/.depend
index 61065a314d..fe54a4fc2e 100644
--- a/ocamldoc/.depend
+++ b/ocamldoc/.depend
@@ -109,7 +109,7 @@ odoc_ast.cmo : \
../typing/predef.cmi \
../typing/path.cmi \
../parsing/parsetree.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_sig.cmi \
@@ -158,7 +158,7 @@ odoc_ast.cmi : \
odoc_module.cmo
odoc_class.cmo : \
../typing/types.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_parameter.cmi \
odoc_name.cmi
@@ -212,7 +212,7 @@ odoc_config.cmi :
odoc_control.cmo :
odoc_control.cmx :
odoc_cross.cmo : \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_search.cmi \
@@ -372,7 +372,7 @@ odoc_html.cmx : \
../parsing/asttypes.cmi
odoc_info.cmo : \
../typing/printtyp.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_text.cmi \
@@ -420,7 +420,7 @@ odoc_info.cmx : \
odoc_info.cmi
odoc_info.cmi : \
../typing/types.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_search.cmi \
@@ -473,7 +473,7 @@ odoc_man.cmx : \
odoc_info.cmx \
../parsing/asttypes.cmi
odoc_merge.cmo : \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_parameter.cmi \
@@ -531,7 +531,7 @@ odoc_misc.cmi : \
../parsing/asttypes.cmi
odoc_module.cmo : \
../typing/types.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_name.cmi \
@@ -599,7 +599,7 @@ odoc_print.cmx : \
odoc_print.cmi : \
../typing/types.cmi
odoc_scan.cmo : \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_module.cmo \
@@ -615,7 +615,7 @@ odoc_scan.cmx : \
odoc_exception.cmx \
odoc_class.cmx
odoc_search.cmo : \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_module.cmo \
@@ -635,7 +635,7 @@ odoc_search.cmx : \
odoc_class.cmx \
odoc_search.cmi
odoc_search.cmi : \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_module.cmo \
@@ -650,7 +650,7 @@ odoc_sig.cmo : \
../typing/types.cmi \
../typing/typedtree.cmi \
../parsing/parsetree.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_types.cmi \
odoc_type.cmo \
odoc_parameter.cmi \
@@ -708,7 +708,7 @@ odoc_sig.cmi : \
odoc_str.cmo : \
../typing/types.cmi \
../typing/printtyp.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_type.cmo \
odoc_print.cmi \
odoc_name.cmi \
@@ -735,7 +735,7 @@ odoc_str.cmx : \
odoc_str.cmi
odoc_str.cmi : \
../typing/types.cmi \
- odoc_value.cmo \
+ odoc_value.cmi \
odoc_type.cmo \
odoc_extension.cmo \
odoc_exception.cmo \
@@ -828,14 +828,21 @@ odoc_value.cmo : \
odoc_parameter.cmi \
odoc_name.cmi \
odoc_misc.cmi \
- ../parsing/asttypes.cmi
+ ../parsing/asttypes.cmi \
+ odoc_value.cmi
odoc_value.cmx : \
../typing/types.cmx \
odoc_types.cmx \
odoc_parameter.cmx \
odoc_name.cmx \
odoc_misc.cmx \
- ../parsing/asttypes.cmi
+ ../parsing/asttypes.cmi \
+ odoc_value.cmi
+odoc_value.cmi : \
+ ../typing/types.cmi \
+ odoc_types.cmi \
+ odoc_parameter.cmi \
+ odoc_name.cmi
generators/odoc_literate.cmo : \
odoc_info.cmi \
odoc_html.cmo \
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index f0f9f2fbad..9d8f0281cb 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -35,7 +35,7 @@ OCAMLDOC_LIBCMXA=odoc_info.cmxa
OCAMLDOC_LIBA=odoc_info.$(A)
OCAMLDOC_LIBMLIS=$(addsuffix .mli,\
- odoc_info odoc_text_lexer odoc_messages odoc_parameter)
+ odoc_info odoc_text_lexer odoc_messages odoc_parameter odoc_value)
OCAMLDOC_LIBCMIS=$(OCAMLDOC_LIBMLIS:.mli=.cmi)
OCAMLDOC_LIBCMTS=$(OCAMLDOC_LIBMLIS:.mli=.cmt) $(OCAMLDOC_LIBMLIS:.mli=.cmti)
diff --git a/ocamldoc/odoc_value.ml b/ocamldoc/odoc_value.ml
index ee15ace48e..aa69cb3084 100644
--- a/ocamldoc/odoc_value.ml
+++ b/ocamldoc/odoc_value.ml
@@ -17,9 +17,6 @@
module Name = Odoc_name
-(** Types *)
-
-(** Representation of a value. *)
type t_value = {
val_name : Name.t ;
mutable val_info : Odoc_types.info option ;
@@ -30,7 +27,6 @@ type t_value = {
mutable val_loc : Odoc_types.location ;
}
-(** Representation of a class attribute. *)
type t_attribute = {
att_value : t_value ; (** an attribute has almost all the same information
as a value *)
@@ -38,7 +34,6 @@ type t_attribute = {
att_virtual : bool ;
}
-(** Representation of a class method. *)
type t_method = {
met_value : t_value ; (** a method has almost all the same information
as a value *)
@@ -46,10 +41,6 @@ type t_method = {
met_virtual : bool ;
}
-(** Functions *)
-
-(** Returns the text associated to the given parameter name
- in the given value, or None. *)
let value_parameter_text_by_name v name =
match v.val_info with
None -> None
@@ -61,7 +52,6 @@ let value_parameter_text_by_name v name =
Not_found ->
None
-(** Update the parameters text of a t_value, according to the val_info field. *)
let update_value_parameters_text v =
let f p =
Odoc_parameter.update_parameter_text (value_parameter_text_by_name v) p
@@ -92,11 +82,6 @@ let parameter_list_from_arrows typ =
in
iter typ
-(** Create a list of parameters with dummy names "??" from a type list.
- Used when we want to merge the parameters of a value, from the .ml
- and the .mli file. In the .mli file we don't have parameter names
- so there is nothing to merge. With this dummy list we can merge the
- parameter names from the .ml and the type from the .mli file. *)
let dummy_parameter_list typ =
let normal_name = Odoc_misc.label_name in
let liste_param = parameter_list_from_arrows typ in
@@ -125,7 +110,6 @@ let dummy_parameter_list typ =
in
List.map iter liste_param
-(** Return true if the value is a function, i.e. has a functional type.*)
let is_function v =
let rec f t =
match Types.get_desc t with
diff --git a/ocamldoc/odoc_value.mli b/ocamldoc/odoc_value.mli
new file mode 100644
index 0000000000..c693c3cb47
--- /dev/null
+++ b/ocamldoc/odoc_value.mli
@@ -0,0 +1,64 @@
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Sebastien Hinderer, projet Cambium, INRIA Paris *)
+(* *)
+(* Copyright 2022 Institut National de Recherche en Informatique et *)
+(* en Automatique. *)
+(* *)
+(* All rights reserved. This file is distributed under the terms of *)
+(* the GNU Lesser General Public License version 2.1, with the *)
+(* special exception on linking described in the file LICENSE. *)
+(* *)
+(**************************************************************************)
+
+(** Representation and manipulation of values, class attributes and class methods. *)
+
+module Name = Odoc_name
+
+(** Types *)
+
+type t_value = {
+ val_name : Name.t;
+ mutable val_info : Odoc_types.info option;
+ val_type : Types.type_expr;
+ val_recursive : bool;
+ mutable val_parameters : Odoc_parameter.parameter list;
+ mutable val_code : string option;
+ mutable val_loc : Odoc_types.location;
+}
+(** Representation of a value. *)
+
+type t_attribute = {
+ att_value : t_value;
+ att_mutable : bool;
+ att_virtual : bool;
+}
+(** Representation of a class attribute. *)
+
+type t_method = {
+ met_value : t_value;
+ met_private : bool;
+ met_virtual : bool;
+}
+(** Representation of a class method. *)
+
+(** Functions *)
+
+val value_parameter_text_by_name : t_value -> string -> Odoc_types.text option
+(** Returns the text associated to the given parameter name
+ in the given value, or None. *)
+
+val update_value_parameters_text : t_value -> unit
+(** Update the parameters text of a t_value, according to the val_info field. *)
+
+val dummy_parameter_list : Types.type_expr -> Odoc_parameter.param_info list
+(** Create a list of parameters with dummy names "??" from a type list.
+ Used when we want to merge the parameters of a value, from the .ml
+ and the .mli file. In the .mli file we don't have parameter names
+ so there is nothing to merge. With this dummy list we can merge the
+ parameter names from the .ml and the type from the .mli file. *)
+
+val is_function : t_value -> bool
+(** Return true if the value is a function, i.e. has a functional type.*)