@@ -11,23 +11,28 @@ type item =
11
11
| Class of Class .t
12
12
| Extension of Extension .t
13
13
| ModuleType of ModuleType .t
14
- | Doc of Comment .docs_or_stop
14
+ | Doc of Paths.Identifier.LabelParent .t * Comment .docs_or_stop
15
15
16
16
let rec unit ~f acc u =
17
17
let acc = f acc (CompilationUnit u) in
18
- match u.content with Module m -> signature ~f acc m | Pack _ -> acc
18
+ match u.content with
19
+ | Module m -> signature ~f (u.id :> Paths.Identifier.LabelParent.t ) acc m
20
+ | Pack _ -> acc
19
21
20
22
and page ~f acc p =
21
23
let open Page in
22
- docs ~f acc (`Docs p.content)
24
+ docs ~f (p.name :> Paths.Identifier.LabelParent.t ) acc (`Docs p.content)
23
25
24
- and signature ~f acc (s : Signature.t ) =
25
- List. fold_left (signature_item ~f ) acc s.items
26
+ and signature ~f id acc (s : Signature.t ) =
27
+ List. fold_left
28
+ (signature_item ~f (id :> Paths.Identifier.LabelParent.t ))
29
+ acc s.items
26
30
27
- and signature_item ~f acc s_item =
31
+ and signature_item ~f id acc s_item =
28
32
match s_item with
29
- | Module (_ , m ) -> module_ ~f acc m
30
- | ModuleType mt -> module_type ~f acc mt
33
+ | Module (_ , m ) -> module_ ~f (m.id :> Paths.Identifier.LabelParent.t ) acc m
34
+ | ModuleType mt ->
35
+ module_type ~f (mt.id :> Paths.Identifier.LabelParent.t ) acc mt
31
36
| ModuleSubstitution _ -> acc
32
37
| ModuleTypeSubstitution _ -> acc
33
38
| Open _ -> acc
@@ -36,43 +41,46 @@ and signature_item ~f acc s_item =
36
41
| TypExt te -> type_extension ~f acc te
37
42
| Exception exc -> exception_ ~f acc exc
38
43
| Value v -> value ~f acc v
39
- | Class (_ , cl ) -> class_ ~f acc cl
40
- | ClassType (_ , clt ) -> class_type ~f acc clt
41
- | Include i -> include_ ~f acc i
42
- | Comment d -> docs ~f acc d
44
+ | Class (_ , cl ) -> class_ ~f (cl.id :> Paths.Identifier.LabelParent.t ) acc cl
45
+ | ClassType (_ , clt ) ->
46
+ class_type ~f (clt.id :> Paths.Identifier.LabelParent.t ) acc clt
47
+ | Include i -> include_ ~f id acc i
48
+ | Comment d -> docs ~f id acc d
43
49
44
- and docs ~f acc d = f acc (Doc d )
50
+ and docs ~f id acc d = f acc (Doc (id, d) )
45
51
46
- and include_ ~f acc inc = signature ~f acc inc.expansion.content
52
+ and include_ ~f id acc inc = signature ~f id acc inc.expansion.content
47
53
48
- and class_type ~f acc ct =
54
+ and class_type ~f id acc ct =
49
55
(* This check is important because [is_internal] does not work on children of
50
56
internal items. This means that if [Fold] did not make this check here,
51
57
it would be difficult to filter for internal items afterwards. This also
52
58
applies to the same check in functions bellow. *)
53
59
if Paths.Identifier. is_internal ct.id then acc
54
60
else
55
61
let acc = f acc (ClassType ct) in
56
- match ct.expansion with None -> acc | Some cs -> class_signature ~f acc cs
62
+ match ct.expansion with
63
+ | None -> acc
64
+ | Some cs -> class_signature ~f id acc cs
57
65
58
- and class_signature ~f acc ct_expr =
59
- List. fold_left (class_signature_item ~f ) acc ct_expr.items
66
+ and class_signature ~f id acc ct_expr =
67
+ List. fold_left (class_signature_item ~f id ) acc ct_expr.items
60
68
61
- and class_signature_item ~f acc item =
69
+ and class_signature_item ~f id acc item =
62
70
match item with
63
71
| Method m -> f acc (Method m)
64
72
| InstanceVariable _ -> acc
65
73
| Constraint _ -> acc
66
74
| Inherit _ -> acc
67
- | Comment d -> docs ~f acc d
75
+ | Comment d -> docs ~f id acc d
68
76
69
- and class_ ~f acc cl =
77
+ and class_ ~f id acc cl =
70
78
if Paths.Identifier. is_internal cl.id then acc
71
79
else
72
80
let acc = f acc (Class cl) in
73
81
match cl.expansion with
74
82
| None -> acc
75
- | Some cl_signature -> class_signature ~f acc cl_signature
83
+ | Some cl_signature -> class_signature ~f id acc cl_signature
76
84
77
85
and exception_ ~f acc exc =
78
86
if Paths.Identifier. is_internal exc.id then acc else f acc (Exception exc)
@@ -82,45 +90,48 @@ and type_extension ~f acc te = f acc (Extension te)
82
90
and value ~f acc v =
83
91
if Paths.Identifier. is_internal v.id then acc else f acc (Value v)
84
92
85
- and module_ ~f acc m =
93
+ and module_ ~f id acc m =
86
94
if Paths.Identifier. is_internal m.id then acc
87
95
else
88
96
let acc = f acc (Module m) in
89
97
match m.type_ with
90
98
| Alias (_ , None) -> acc
91
- | Alias (_ , Some s_e ) -> simple_expansion ~f acc s_e
92
- | ModuleType mte -> module_type_expr ~f acc mte
99
+ | Alias (_ , Some s_e ) -> simple_expansion ~f id acc s_e
100
+ | ModuleType mte -> module_type_expr ~f id acc mte
93
101
94
102
and type_decl ~f acc td =
95
103
if Paths.Identifier. is_internal td.id then acc else f acc (TypeDecl td)
96
104
97
- and module_type ~f acc mt =
105
+ and module_type ~f id acc mt =
98
106
if Paths.Identifier. is_internal mt.id then acc
99
107
else
100
108
let acc = f acc (ModuleType mt) in
101
109
match mt.expr with
102
110
| None -> acc
103
- | Some mt_expr -> module_type_expr ~f acc mt_expr
111
+ | Some mt_expr -> module_type_expr ~f id acc mt_expr
104
112
105
- and simple_expansion ~f acc s_e =
113
+ and simple_expansion ~f id acc s_e =
106
114
match s_e with
107
- | Signature sg -> signature ~f acc sg
115
+ | Signature sg -> signature ~f id acc sg
108
116
| Functor (p , s_e ) ->
109
117
let acc = functor_parameter ~f acc p in
110
- simple_expansion ~f acc s_e
118
+ simple_expansion ~f id acc s_e
111
119
112
- and module_type_expr ~f acc mte =
120
+ and module_type_expr ~f id acc mte =
113
121
match mte with
114
- | Signature s -> signature ~f acc s
122
+ | Signature s -> signature ~f id acc s
115
123
| Functor (fp , mt_expr ) ->
116
124
let acc = functor_parameter ~f acc fp in
117
- module_type_expr ~f acc mt_expr
118
- | With { w_expansion = Some sg ; _ } -> simple_expansion ~f acc sg
119
- | TypeOf { t_expansion = Some sg ; _ } -> simple_expansion ~f acc sg
120
- | Path { p_expansion = Some sg ; _ } -> simple_expansion ~f acc sg
125
+ module_type_expr ~f id acc mt_expr
126
+ | With { w_expansion = Some sg ; _ } -> simple_expansion ~f id acc sg
127
+ | TypeOf { t_expansion = Some sg ; _ } -> simple_expansion ~f id acc sg
128
+ | Path { p_expansion = Some sg ; _ } -> simple_expansion ~f id acc sg
121
129
| Path { p_expansion = None ; _ } -> acc
122
130
| With { w_expansion = None ; _ } -> acc
123
131
| TypeOf { t_expansion = None ; _ } -> acc
124
132
125
133
and functor_parameter ~f acc fp =
126
- match fp with Unit -> acc | Named n -> module_type_expr ~f acc n.expr
134
+ match fp with
135
+ | Unit -> acc
136
+ | Named n ->
137
+ module_type_expr ~f (n.id :> Paths.Identifier.LabelParent.t ) acc n.expr
0 commit comments