Skip to content

Commit 2c2b7cc

Browse files
authored
Merge pull request #46 from mbarbin/naming-and-doc
Naming and doc
2 parents e952f37 + d6d9c0c commit 2c2b7cc

22 files changed

+193
-168
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### Changed
88

9+
- A breaking renaming in the terminology (kind => status) (#46, @mbarbin).
910
- Add buffer line header in emacs crs-grep-mode by default (#44, @mbarbin).
1011

1112
### Fixed

lib/cr_comment/src/cr_comment.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(********************************************************************************)
2121

22-
module Kind = Kind
22+
module Status = Status
2323
module Filter = Filter
2424
module Priority = Priority
2525
module Qualifier = Qualifier

lib/cr_comment/src/cr_comment.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(*_ <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(*_*******************************************************************************)
2121

22-
module Kind = Kind
22+
module Status = Status
2323
module Filter = Filter
2424
module Priority = Priority
2525
module Qualifier = Qualifier

lib/cr_comment/src/cr_comment0.ml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* - Remove support for extra headers.
6363
* - Remove support for attributes.
6464
* - Remove assignee computation (left as external work).
65-
* - Replace [is_xcr] by a variant type [Kind.t].
65+
* - Replace [is_xcr] by a variant type [Status.t].
6666
* - Make [reporter] mandatory.
6767
* - Refactor [Raw], make [t] a record with a processed part that may fail.
6868
* - Compute [digest_of_condensed_content] for all CR kinds.
@@ -85,7 +85,7 @@ module Header = struct
8585
[@@@coverage off]
8686

8787
type t =
88-
{ kind : Kind.t Loc.Txt.t
88+
{ status : Status.t Loc.Txt.t
8989
; qualifier : Qualifier.t Loc.Txt.t
9090
; reporter : Vcs.User_handle.t Loc.Txt.t
9191
; recipient : Vcs.User_handle.t Loc.Txt.t option
@@ -98,27 +98,30 @@ module Header = struct
9898
module With_loc = struct
9999
let reporter t = t.reporter
100100
let recipient t = t.recipient
101-
let kind t = t.kind
101+
let status t = t.status
102102
let qualifier t = t.qualifier
103103

104104
(* Deprecated. *)
105105
let reported_by = reporter
106106
let for_ = recipient
107107
let due = qualifier
108+
let kind = status
108109
end
109110

110-
let create ~kind ~qualifier ~reporter ~recipient =
111-
{ kind; qualifier; reporter; recipient }
111+
let create ~status ~qualifier ~reporter ~recipient =
112+
{ status; qualifier; reporter; recipient }
112113
;;
113114

114115
let reporter t = t.reporter.txt
115116
let recipient t = Option.map t.recipient ~f:Loc.Txt.txt
116-
let kind t = t.kind.txt
117+
let status t = t.status.txt
117118
let qualifier t = t.qualifier.txt
119+
let priority t = qualifier t |> Qualifier.priority
118120

119121
(* Deprecated. *)
120122
let reported_by = reporter
121123
let for_ = recipient
124+
let kind = status
122125
end
123126

124127
module T = struct
@@ -185,7 +188,7 @@ let reindented_content ?(new_line_prefix = "") t =
185188
(* The len of the indentation is a heuristic in this case. *)
186189
start.pos_cnum - start.pos_bol + String.length t.comment_prefix + 1
187190
| Ok h ->
188-
let start = Loc.start h.kind.loc in
191+
let start = Loc.start h.status.loc in
189192
start.pos_cnum - start.pos_bol)
190193
in
191194
String.make len ' '
@@ -226,19 +229,19 @@ let reindented_content ?(new_line_prefix = "") t =
226229

227230
let sort ts = List.sort ts ~compare:For_sorted_output.compare
228231

229-
let kind t =
232+
let status t : Status.t =
230233
match t.header with
231-
| Error _ -> Kind.CR
232-
| Ok p -> Header.kind p
234+
| Error _ -> CR
235+
| Ok p -> Header.status p
233236
;;
234237

235238
let priority t : Priority.t =
236239
match t.header with
237240
| Error _ -> Now
238241
| Ok p ->
239-
(match Header.kind p with
242+
(match Header.status p with
240243
| XCR -> Now
241-
| CR -> Header.qualifier p |> Qualifier.priority)
244+
| CR -> Header.priority p)
242245
;;
243246

244247
let to_string t =
@@ -272,3 +275,4 @@ end
272275
(* Deprecated *)
273276

274277
let work_on = priority
278+
let kind = status

lib/cr_comment/src/cr_comment0.mli

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ module Header : sig
8989
out, such as in [CR user1: Comment]. *)
9090
val recipient : t -> Vcs.User_handle.t option
9191

92-
val kind : t -> Kind.t
92+
val status : t -> Status.t
9393

9494
(** This returns the qualifier if present ([Soon] for [CR-soon] or [Someday]
9595
for [CR-someday]). If there is no qualifier specified, this returns
9696
[None]. *)
9797
val qualifier : t -> Qualifier.t
9898

99+
(** [priority t] represents the expectation as to when work on the CR is meant
100+
to happen. It is based on the header's qualifier. *)
101+
val priority : t -> Priority.t
102+
99103
module With_loc : sig
100104
(** These getters allows you to access the position of each elements of the
101105
CR header. This is meant for tools processing CRs automatically, such
@@ -113,21 +117,25 @@ module Header : sig
113117
(** The location includes the entire keyword ["CR"] or ["XCR"] depending on
114118
the case. It stops right before the following char, that being a space
115119
or a ['-'] (and thus does not include it). *)
116-
val kind : t -> Kind.t Loc.Txt.t
120+
val status : t -> Status.t Loc.Txt.t
117121

118122
(** When the CR is qualified as [Soon] or [Someday], the location returned
119123
starts right after the dash separator (but does not include it), and
120124
contains the entire qualifier keyword. For example, the location will
121125
include ["soon"] for a [CR-soon]. When the CR has no qualifier, there
122126
is no keyword to attach a location to : conventionally, we return
123-
instead the location of the CR [kind] in this case. *)
127+
instead the location of the CR [status] in this case. *)
124128
val qualifier : t -> Qualifier.t Loc.Txt.t
125129

126130
(** {1 Deprecated}
127131
128132
The following is deprecated and will be soon annotated as such with ocaml
129133
alerts. Please migrate, and do not use in new code. *)
130134

135+
(** This was renamed [status]. Hint: Run [ocamlmig migrate]. *)
136+
val kind : t -> Status.t Loc.Txt.t
137+
[@@migrate { repl = Rel.status }]
138+
131139
(** This was renamed [reporter]. Hint: Run [ocamlmig migrate]. *)
132140
val reported_by : t -> Vcs.User_handle.t Loc.Txt.t
133141
[@@migrate { repl = Rel.reporter }]
@@ -138,7 +146,7 @@ module Header : sig
138146

139147
(** This was renamed [qualifier]. Hint: Run [ocamlmig migrate]. *)
140148
val due : t -> Qualifier.t Loc.Txt.t
141-
[@@migrate { repl = Rel.recipient }]
149+
[@@migrate { repl = Rel.qualifier }]
142150
end
143151

144152
(** {1 Deprecated}
@@ -153,6 +161,10 @@ module Header : sig
153161
(** This was renamed [recipient]. Hint: Run [ocamlmig migrate]. *)
154162
val for_ : t -> Vcs.User_handle.t option
155163
[@@migrate { repl = Rel.recipient }]
164+
165+
(** This was renamed [status]. Hint: Run [ocamlmig migrate]. *)
166+
val kind : t -> Status.t
167+
[@@migrate { repl = Rel.status }]
156168
end
157169

158170
(** A [Cr_comment.t] is an immutable value holding the information and metadata
@@ -172,7 +184,7 @@ val content : t -> string
172184
val whole_loc : t -> Loc.t
173185

174186
val header : t -> Header.t Or_error.t
175-
val kind : t -> Kind.t
187+
val status : t -> Status.t
176188

177189
(** [priority t] represents the expectation as to when work on the CR is meant
178190
to happen. It is based on the header's qualifier except that XCRs and
@@ -228,7 +240,7 @@ module Private : sig
228240

229241
module Header : sig
230242
val create
231-
: kind:Kind.t Loc.Txt.t
243+
: status:Status.t Loc.Txt.t
232244
-> qualifier:Qualifier.t Loc.Txt.t
233245
-> reporter:Vcs.User_handle.t Loc.Txt.t
234246
-> recipient:Vcs.User_handle.t Loc.Txt.t option
@@ -253,3 +265,7 @@ end
253265
(** This was renamed [priority]. Hint: Run [ocamlmig migrate]. *)
254266
val work_on : t -> Priority.t
255267
[@@migrate { repl = Rel.priority }]
268+
269+
(** This was renamed [status]. Hint: Run [ocamlmig migrate]. *)
270+
val kind : t -> Status.t
271+
[@@migrate { repl = Rel.status }]

lib/cr_comment/src/filter.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let matches t ~cr =
5757
(match Cr_comment0.header cr with
5858
| Error _ -> false
5959
| Ok h ->
60-
(match Cr_comment0.Header.kind h with
60+
(match Cr_comment0.Header.status h with
6161
| XCR -> false
6262
| CR ->
6363
(match Cr_comment0.Header.qualifier h with
@@ -67,14 +67,14 @@ let matches t ~cr =
6767
(match Cr_comment0.header cr with
6868
| Error _ -> false
6969
| Ok h ->
70-
(match Cr_comment0.Header.kind h with
70+
(match Cr_comment0.Header.status h with
7171
| CR -> false
7272
| XCR -> true))
7373
| Now ->
7474
(match Cr_comment0.header cr with
7575
| Error _ -> false
7676
| Ok h ->
77-
(match Cr_comment0.Header.kind h with
77+
(match Cr_comment0.Header.status h with
7878
| XCR -> true
7979
| CR ->
8080
(match Cr_comment0.Header.qualifier h with
@@ -84,7 +84,7 @@ let matches t ~cr =
8484
(match Cr_comment0.header cr with
8585
| Error _ -> false
8686
| Ok h ->
87-
(match Cr_comment0.Header.kind h with
87+
(match Cr_comment0.Header.status h with
8888
| XCR -> false
8989
| CR ->
9090
(match Cr_comment0.Header.qualifier h with
@@ -94,7 +94,7 @@ let matches t ~cr =
9494
(match Cr_comment0.header cr with
9595
| Error _ -> false
9696
| Ok h ->
97-
(match Cr_comment0.Header.kind h with
97+
(match Cr_comment0.Header.status h with
9898
| XCR -> false
9999
| CR ->
100100
(match Cr_comment0.Header.qualifier h with

lib/cr_comment/src/priority.mli

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(** The [Priority.t] type represents a priority classification that can be
2323
associated with a code review comment (CR). Assignment of a priority is
2424
not always direct; rather, it is typically computed as a function of other
25-
elements such as the CR's kind, review context, and qualifier.
25+
elements such as the CR's status, review context, and qualifier.
2626
2727
This classification is intended as a general convenience to help organize
2828
and filter CRs by indicating the reviewers's intent or suggested importance,
@@ -33,6 +33,10 @@
3333
at this level. Higher-level tools or code review systems built on top of CRs
3434
may define their own policies or behaviors around these categories.
3535
36+
In the terminology used in the project, you'll sometimes come across
37+
language that makes a direct parallel between the CR's priority, and when
38+
work on it is expected to be "due" or meant to happen.
39+
3640
Typical interpretations:
3741
- [Now]: Should be addressed promptly (while working on a PR for example).
3842
- [Soon]: Should be addressed in the near future.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(*_ <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(*_*******************************************************************************)
2121

22-
(** The [Kind.t] type distinguishes between resolved and unresolved code review
22+
(** The [Status.t] type distinguishes between resolved and unresolved code review
2323
comments.
2424
2525
- [CR]: An unresolved code review comment.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
(********************************************************************************)
2121

2222
let%expect_test "to_string" =
23-
List.iter Cr_comment.Kind.all ~f:(fun kind ->
23+
List.iter Cr_comment.Status.all ~f:(fun status ->
2424
print_s
2525
[%sexp
26-
{ kind : Cr_comment.Kind.t
27-
; to_string = (Cr_comment.Kind.to_string kind : string)
26+
{ status : Cr_comment.Status.t
27+
; to_string = (Cr_comment.Status.to_string status : string)
2828
}]);
2929
[%expect
3030
{|
31-
((kind CR)
31+
((status CR)
3232
(to_string CR))
33-
((kind XCR)
33+
((status XCR)
3434
(to_string XCR))
3535
|}];
3636
()

0 commit comments

Comments
 (0)