1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 2001 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. *)
(* *)
(**************************************************************************)
(** Scanning of modules and elements.
The class scanner defined in this module can be used to
develop generators which perform controls on the elements
and their comments.
*)
open Odoc_types
(** Class which defines the scanning of a list of modules and their
elements. Inherit this class to develop your own scanner, by
overriding some methods.*)
class scanner =
object (self)
method scan_value (_ : Odoc_value.t_value) = ()
method scan_type_pre (_ : Odoc_type.t_type) = true
method scan_type_recfield _t (_ : Odoc_type.record_field) = ()
method scan_type_const _t (_ : Odoc_type.variant_constructor) = ()
method scan_type (t : Odoc_type.t_type) =
if self#scan_type_pre t then
match t.Odoc_type.ty_kind with
Odoc_type.Type_abstract -> ()
| Odoc_type.Type_variant l -> List.iter (self#scan_type_const t) l
| Odoc_type.Type_record l -> List.iter (self#scan_type_recfield t) l
| Odoc_type.Type_open -> ()
method scan_extension_constructor (_ : Odoc_extension.t_extension_constructor) = ()
method scan_exception (_ : Odoc_exception.t_exception) = ()
method scan_attribute (_ : Odoc_value.t_attribute) = ()
method scan_method (_ : Odoc_value.t_method) = ()
method scan_included_module (_ : Odoc_module.included_module) = ()
(** Scan of a type extension *)
(** Override this method to perform controls on the extension's type,
private and info. This method is called before scanning the
extensions's constructors.
@return true if the extension's constructors must be scanned.*)
method scan_type_extension_pre (_: Odoc_extension.t_type_extension) = true
(** This method scans the constructors of the given type extension. *)
method scan_type_extension_constructors (x: Odoc_extension.t_type_extension) =
List.iter self#scan_extension_constructor (Odoc_extension.extension_constructors x)
(** Scan of a type extension. Should not be overridden. It calls [scan_type_extension_pre]
and if [scan_type_extension_pre] returns [true], then it calls scan_type_extension_constructors.*)
method scan_type_extension (x: Odoc_extension.t_type_extension) =
if self#scan_type_extension_pre x then self#scan_type_extension_constructors x
(** Scan of a class. *)
(** Scan of a comment inside a class. *)
method scan_class_comment (_ : text) = ()
(** Override this method to perform controls on the class comment
and params. This method is called before scanning the class elements.
@return true if the class elements must be scanned.*)
method scan_class_pre (_ : Odoc_class.t_class) = true
(** This method scans the elements of the given class.
A VOIR : scan des classes heritees.*)
method scan_class_elements c =
List.iter
(fun ele ->
match ele with
Odoc_class.Class_attribute a -> self#scan_attribute a
| Odoc_class.Class_method m -> self#scan_method m
| Odoc_class.Class_comment t -> self#scan_class_comment t
)
(Odoc_class.class_elements c)
(** Scan of a class. Should not be overridden. It calls [scan_class_pre]
and if [scan_class_pre] returns [true], then it calls scan_class_elements.*)
method scan_class c = if self#scan_class_pre c then self#scan_class_elements c
(** Scan of a class type. *)
(** Scan of a comment inside a class type. *)
method scan_class_type_comment (_ : text) = ()
(** Override this method to perform controls on the class type comment
and form. This method is called before scanning the class type elements.
@return true if the class type elements must be scanned.*)
method scan_class_type_pre (_ : Odoc_class.t_class_type) = true
(** This method scans the elements of the given class type.
A VOIR : scan des classes heritees.*)
method scan_class_type_elements ct =
List.iter
(fun ele ->
match ele with
Odoc_class.Class_attribute a -> self#scan_attribute a
| Odoc_class.Class_method m -> self#scan_method m
| Odoc_class.Class_comment t -> self#scan_class_type_comment t
)
(Odoc_class.class_type_elements ct)
(** Scan of a class type. Should not be overridden. It calls [scan_class_type_pre]
and if [scan_class_type_pre] returns [true], then it calls scan_class_type_elements.*)
method scan_class_type ct = if self#scan_class_type_pre ct then self#scan_class_type_elements ct
(** Scan of modules. *)
(** Scan of a comment inside a module. *)
method scan_module_comment (_ : text) = ()
(** Override this method to perform controls on the module comment
and form. This method is called before scanning the module elements.
@return true if the module elements must be scanned.*)
method scan_module_pre (_ : Odoc_module.t_module) = true
(** This method scans the elements of the given module. *)
method scan_module_elements m =
List.iter
(fun ele ->
match ele with
Odoc_module.Element_module m -> self#scan_module m
| Odoc_module.Element_module_type mt -> self#scan_module_type mt
| Odoc_module.Element_included_module im -> self#scan_included_module im
| Odoc_module.Element_class c -> self#scan_class c
| Odoc_module.Element_class_type ct -> self#scan_class_type ct
| Odoc_module.Element_value v -> self#scan_value v
| Odoc_module.Element_type_extension x -> self#scan_type_extension x
| Odoc_module.Element_exception e -> self#scan_exception e
| Odoc_module.Element_type t -> self#scan_type t
| Odoc_module.Element_module_comment t -> self#scan_module_comment t
)
(Odoc_module.module_elements m)
(** Scan of a module. Should not be overridden. It calls [scan_module_pre]
and if [scan_module_pre] returns [true], then it calls scan_module_elements.*)
method scan_module m = if self#scan_module_pre m then self#scan_module_elements m
(** Scan of module types. *)
(** Scan of a comment inside a module type. *)
method scan_module_type_comment (_ : text) = ()
(** Override this method to perform controls on the module type comment
and form. This method is called before scanning the module type elements.
@return true if the module type elements must be scanned. *)
method scan_module_type_pre (_ : Odoc_module.t_module_type) = true
(** This method scans the elements of the given module type. *)
method scan_module_type_elements mt =
List.iter
(fun ele ->
match ele with
Odoc_module.Element_module m -> self#scan_module m
| Odoc_module.Element_module_type mt -> self#scan_module_type mt
| Odoc_module.Element_included_module im -> self#scan_included_module im
| Odoc_module.Element_class c -> self#scan_class c
| Odoc_module.Element_class_type ct -> self#scan_class_type ct
| Odoc_module.Element_value v -> self#scan_value v
| Odoc_module.Element_type_extension x -> self#scan_type_extension x
| Odoc_module.Element_exception e -> self#scan_exception e
| Odoc_module.Element_type t -> self#scan_type t
| Odoc_module.Element_module_comment t -> self#scan_module_comment t
)
(Odoc_module.module_type_elements mt)
(** Scan of a module type. Should not be overridden. It calls [scan_module_type_pre]
and if [scan_module_type_pre] returns [true], then it calls scan_module_type_elements.*)
method scan_module_type mt =
if self#scan_module_type_pre mt then self#scan_module_type_elements mt
(** Main scanning method. *)
(** Scan a list of modules. *)
method scan_module_list l = List.iter self#scan_module l
end
|