Skip to content

Commit e62ad5b

Browse files
panglesdjonludlam
authored andcommitted
Occurrences: change option from -include-persistent to -include-own
We always want to include persistents, the question is whether we want to include the non-persistent ident! Signed-off-by: Paul-Elliot <[email protected]>
1 parent bb0d859 commit e62ad5b

File tree

3 files changed

+55
-28
lines changed

3 files changed

+55
-28
lines changed

src/odoc/bin/main.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,11 +1112,11 @@ end
11121112

11131113
module Occurrences = struct
11141114
module Count = struct
1115-
let count directories dst warnings_options include_hidden include_persistent
1115+
let count directories dst warnings_options include_hidden include_own
11161116
=
11171117
let dst = Fpath.v dst in
11181118
Occurrences.count ~dst ~warnings_options directories include_hidden
1119-
include_persistent
1119+
include_own
11201120

11211121
let cmd =
11221122
let dst =
@@ -1130,17 +1130,16 @@ module Occurrences = struct
11301130
let doc = "Include hidden identifiers in the table" in
11311131
Arg.(value & flag & info ~docs ~doc [ "include-hidden" ])
11321132
in
1133-
let include_persistent =
1133+
let include_own =
11341134
let doc =
1135-
"Include persistent identifiers in the table: occurrences of in ids \
1136-
intheir own implementation."
1135+
"Include identifiers from the compilation in the table."
11371136
in
1138-
Arg.(value & flag & info ~docs ~doc [ "include-persistent" ])
1137+
Arg.(value & flag & info ~docs ~doc [ "include-own" ])
11391138
in
11401139
Term.(
11411140
const handle_error
11421141
$ (const count $ odoc_file_directories $ dst $ warnings_options
1143-
$ include_hidden $ include_persistent))
1142+
$ include_hidden $ include_own))
11441143

11451144
let info ~docs =
11461145
let doc =

src/odoc/occurrences.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ end = struct
119119
tbl
120120
end
121121

122-
let count ~dst ~warnings_options:_ directories include_hidden include_persistent
122+
let count ~dst ~warnings_options:_ directories include_hidden include_own
123123
=
124124
let htbl = H.create 100 in
125125
let f () (unit : Odoc_model.Lang.Compilation_unit.t) =
126126
let incr tbl p persistent =
127127
let p = (p :> Odoc_model.Paths.Path.Resolved.t) in
128128
let id = Odoc_model.Paths.Path.Resolved.identifier p in
129129
if (not (Odoc_model.Paths.Path.Resolved.is_hidden p)) || include_hidden
130-
then if (not persistent) || include_persistent then Occtbl.add tbl id
130+
then if persistent || include_own then Occtbl.add tbl id
131131
in
132132
let () =
133133
List.iter

test/occurrences/double_wrapped.t/run.t

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,25 @@ Uses of B.Z are not counted since they go to a hidden module.
5757
Uses of values Y.x and Z.y (in b.ml) are not counted since they come from a "local" module.
5858

5959
$ occurrences_print main.occ | sort
60+
Main was used directly 0 times and indirectly 2 times
61+
Main.A was used directly 1 times and indirectly 0 times
62+
Main.B was used directly 1 times and indirectly 0 times
6063

6164
$ occurrences_print main__.occ | sort
6265

6366
$ occurrences_print main__A.occ | sort
64-
string was used directly 1 times and indirectly 0 times
6567

6668
$ occurrences_print main__B.occ | sort
67-
Main was used directly 0 times and indirectly 1 times
68-
Main.A was used directly 0 times and indirectly 1 times
69+
Main was used directly 0 times and indirectly 7 times
70+
Main.A was used directly 2 times and indirectly 5 times
71+
Main.A.(||>) was used directly 1 times and indirectly 0 times
72+
Main.A.M was used directly 2 times and indirectly 0 times
73+
Main.A.t was used directly 1 times and indirectly 0 times
6974
Main.A.x was used directly 1 times and indirectly 0 times
7075

7176
$ occurrences_print main__C.occ | sort
72-
Main was used directly 0 times and indirectly 1 times
73-
Main.A was used directly 0 times and indirectly 1 times
77+
Main was used directly 0 times and indirectly 2 times
78+
Main.A was used directly 1 times and indirectly 1 times
7479
Main.A.x was used directly 1 times and indirectly 0 times
7580

7681
Now we can merge both files
@@ -83,23 +88,40 @@ Now we can merge both files
8388
$ odoc aggregate-occurrences main.occ main__.occ --file-list files.map -o aggregated.txt
8489

8590
$ occurrences_print aggregated.txt | sort
86-
Main was used directly 0 times and indirectly 2 times
87-
Main.A was used directly 0 times and indirectly 2 times
91+
Main was used directly 0 times and indirectly 11 times
92+
Main.A was used directly 4 times and indirectly 6 times
93+
Main.A.(||>) was used directly 1 times and indirectly 0 times
94+
Main.A.M was used directly 2 times and indirectly 0 times
95+
Main.A.t was used directly 1 times and indirectly 0 times
8896
Main.A.x was used directly 2 times and indirectly 0 times
89-
string was used directly 1 times and indirectly 0 times
97+
Main.B was used directly 1 times and indirectly 0 times
9098

9199
Compare with the one created directly with all occurrences:
92100

93101
$ odoc count-occurrences -I . -o occurrences.txt
94102
$ occurrences_print occurrences.txt | sort
95-
Main was used directly 0 times and indirectly 2 times
96-
Main.A was used directly 0 times and indirectly 2 times
103+
Main was used directly 0 times and indirectly 11 times
104+
Main.A was used directly 4 times and indirectly 6 times
105+
Main.A.(||>) was used directly 1 times and indirectly 0 times
106+
Main.A.M was used directly 2 times and indirectly 0 times
107+
Main.A.t was used directly 1 times and indirectly 0 times
97108
Main.A.x was used directly 2 times and indirectly 0 times
98-
string was used directly 1 times and indirectly 0 times
109+
Main.B was used directly 1 times and indirectly 0 times
99110

100111
We can also include persistent ids, and hidden ids:
101112

102-
$ odoc count-occurrences -I . -o occurrences.txt --include-persistent
113+
$ odoc count-occurrences -I main__A -o occurrences.txt --include-own
114+
$ occurrences_print occurrences.txt | sort
115+
string was used directly 1 times and indirectly 0 times
116+
117+
$ odoc count-occurrences -I main__A -o occurrences.txt --include-hidden
118+
$ occurrences_print occurrences.txt | sort
119+
120+
$ odoc count-occurrences -I main__A -o occurrences.txt --include-own --include-hidden
121+
$ occurrences_print occurrences.txt | sort
122+
string was used directly 1 times and indirectly 0 times
123+
124+
$ odoc count-occurrences -I . -o occurrences.txt --include-own
103125
$ occurrences_print occurrences.txt | sort
104126
Main was used directly 0 times and indirectly 13 times
105127
Main.A was used directly 4 times and indirectly 8 times
@@ -112,15 +134,21 @@ We can also include persistent ids, and hidden ids:
112134

113135
$ odoc count-occurrences -I . -o occurrences.txt --include-hidden
114136
$ occurrences_print occurrences.txt | sort
115-
Main was used directly 0 times and indirectly 2 times
116-
Main.A was used directly 0 times and indirectly 2 times
137+
Main was used directly 0 times and indirectly 11 times
138+
Main.A was used directly 4 times and indirectly 6 times
139+
Main.A.(||>) was used directly 1 times and indirectly 0 times
140+
Main.A.M was used directly 2 times and indirectly 0 times
141+
Main.A.t was used directly 1 times and indirectly 0 times
117142
Main.A.x was used directly 2 times and indirectly 0 times
118-
Main__B was used directly 0 times and indirectly 1 times
119-
Main__B.Z was used directly 0 times and indirectly 1 times
120-
Main__B.Z.y was used directly 1 times and indirectly 0 times
121-
string was used directly 1 times and indirectly 0 times
143+
Main.B was used directly 1 times and indirectly 0 times
144+
Main__ was used directly 0 times and indirectly 2 times
145+
Main__.C was used directly 1 times and indirectly 1 times
146+
Main__.C.y was used directly 1 times and indirectly 0 times
147+
Main__A was used directly 1 times and indirectly 0 times
148+
Main__B was used directly 1 times and indirectly 0 times
149+
Main__C was used directly 1 times and indirectly 0 times
122150

123-
$ odoc count-occurrences -I . -o occurrences.txt --include-persistent --include-hidden
151+
$ odoc count-occurrences -I . -o occurrences.txt --include-own --include-hidden
124152
$ occurrences_print occurrences.txt | sort
125153
Main was used directly 0 times and indirectly 13 times
126154
Main.A was used directly 4 times and indirectly 8 times

0 commit comments

Comments
 (0)