Skip to content

Commit 039e1a6

Browse files
authored
Merge pull request #26 from mbarbin/improve-doc
Improve odoc documentation
2 parents c7d5b2c + 8d4ea0b commit 039e1a6

File tree

8 files changed

+115
-35
lines changed

8 files changed

+115
-35
lines changed

.vscode/settings.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
11
{
22
"cSpell.words": [
33
"chdir",
4+
"cmdlang",
5+
"cmdliner",
6+
"codemods",
7+
"compl",
8+
"conv",
9+
"descr",
10+
"Diátaxis",
11+
"docstrings",
412
"docv",
13+
"EINTR",
14+
"fname",
515
"Fpath",
16+
"Fsegment",
617
"janestreet",
18+
"jdoe",
19+
"lnum",
20+
"MELPA",
721
"odoc",
822
"opam",
23+
"pageantty",
924
"patdiff",
25+
"pplumbing",
26+
"ppxlib",
1027
"reindentation",
1128
"reindented",
29+
"relpath",
30+
"repn",
31+
"sherlodoc",
1232
"shexp",
1333
"sigpipe",
14-
"volgo"
34+
"textutils",
35+
"volgo",
36+
"waitpid",
37+
"WEXITED",
38+
"WSIGNALED",
39+
"WSTOPPED"
1540
]
1641
}

NOTICE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Licence
1+
# License
22

33
crs is released under the terms of the `LGPL-3.0-or-later WITH LGPL-3.0-linking-exception` license.
44

lib/cr_comment/src/cr_comment.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@
6666
* - Make [reported_by] 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.
69-
* - Remove special type for cr soons. Return all CRs parsed.
7069
* - Rename [Processed] to [Header].
71-
* - Remove support for printing crs without their content.
70+
* - Remove support for printing CRs without their content.
7271
* - Compute positions and offsets with [Loc].
7372
* - Some minor changes to the [reindented] content rendering.
7473
*)
@@ -194,7 +193,7 @@ let reindented_content t =
194193
| Some s -> " " ^ s))
195194
with
196195
| exception Stdlib.Exit -> str
197-
| deindented_lines -> String.concat deindented_lines ~sep:"\n"
196+
| lines -> String.concat lines ~sep:"\n"
198197
;;
199198

200199
let sort ts = List.sort ts ~compare:For_sorted_output.compare

lib/cr_comment/src/cr_comment.mli

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* Changes: ...
4242
*
4343
* - Remove dependency to [Core] and [Async].
44-
* - Remove the [Stable] module - unversion the code.
44+
* - Remove the [Stable] module - remove the versioning of the code.
4545
* - Replace [Relpath] by [Vcs.Path_in_repo].
4646
* - Remove [of_sexp] constructs.
4747
* - Remove [Cr_comment_format].
@@ -57,20 +57,48 @@
5757
* - Remove support for attributes.
5858
* - Remove assignee computation (left as external work).
5959
* - Do not export [Raw].
60-
* - Remove special type for cr soons. Return all CRs parsed.
6160
* - Rename [Processed] to [Header].
62-
* - Remove support for printing crs without their content.
61+
* - Remove support for printing CRs without their content.
6362
* - Compute positions and offsets with [Loc].
6463
*)
6564

65+
(** Code review comments embedded in source code.
66+
67+
This module provides the core types and functions for representing and
68+
manipulating code review comments (CRs) embedded directly in source code
69+
using a special syntax. A CR captures actionable feedback, metadata, and
70+
assignment information, supporting workflows for tracking, resolving, and
71+
managing code review discussions within the codebase. *)
72+
6673
module Kind : sig
74+
(** The [Kind.t] type distinguishes between active and resolved code review
75+
comments.
76+
- [CR]: An active code review comment.
77+
- [XCR]: A resolved code review comment. *)
6778
type t =
6879
| CR
6980
| XCR
7081
[@@deriving compare, equal, sexp_of]
7182
end
7283

7384
module Due : sig
85+
(** The [Due.t] type represents an optional urgency or priority class that can
86+
be attached to a code review comment (CR) using the CR syntax. This
87+
classification is a general convenience provided by the library to help
88+
organize and filter CRs, but the exact workflow and expectations
89+
associated with each class — such as when a [Soon] or [Someday] comment
90+
should be addressed — are intentionally left undefined here.
91+
92+
It is up to higher-level tools or code review systems built on top of CRs
93+
to define and enforce specific policies or behaviors around these classes.
94+
95+
As a rule of thumb:
96+
- [Now]: Should be addressed promptly.
97+
- [Soon]: Should be addressed in the near future.
98+
- [Someday]: Can be deferred until later.
99+
100+
These categories are intended to be flexible and adaptable to the needs of
101+
various development process. *)
74102
type t =
75103
| Now
76104
| Soon
@@ -91,8 +119,9 @@ module Header : sig
91119
(** [reported_by] is [user] in [CR user...]. *)
92120
val reported_by : t -> Vcs.User_handle.t
93121

94-
(** [for_] is [user2] in [CR user1 for user2: ...]. It is none since the part
95-
with the [for user2] is optional. *)
122+
(** [for_] is [user2] in [CR user1 for user2: ...]. Assigning CRs to
123+
particular users is optional. This returns [None] if that part is left
124+
out, such as in [CR user1: Comment]. *)
96125
val for_ : t -> Vcs.User_handle.t option
97126

98127
val kind : t -> Kind.t
@@ -104,14 +133,14 @@ module Header : sig
104133
module With_loc : sig
105134
(** These getters allows you to access the position of each elements of the
106135
CR header. This is meant for tools processing CRs automatically, such
107-
as CR comment rewriters. *)
136+
as CRs rewriters. *)
108137

109138
(** The location includes the entire reporter username, without the
110139
surrounding spaces. *)
111140
val reported_by : t -> Vcs.User_handle.t Loc.Txt.t
112141

113142
(** The location includes the entire assignee username, if it is present,
114-
without the surround spaces. In particular, the location does not
143+
without the surrounding spaces. In particular, the location does not
115144
include the ["for"] keyword itself. *)
116145
val for_ : t -> Vcs.User_handle.t Loc.Txt.t option
117146

@@ -123,21 +152,23 @@ module Header : sig
123152
(** When the CR is due [Soon] or [Someday], the location returned starts
124153
right after the dash separator (but does not include it), and contains
125154
the entire due keyword. For example, the location will include
126-
["soon"] for a [CR-soon]. When the cr is due [Now], there is no
155+
["soon"] for a [CR-soon]. When the CR is due [Now], there is no
127156
keyword to attach a location to : conventionally, we return instead
128-
the location of the cr [kind] in this case. *)
157+
the location of the CR [kind] in this case. *)
129158
val due : t -> Due.t Loc.Txt.t
130159
end
131160
end
132161

162+
(** A [Cr_comment.t] is an immutable value holding the information and metadata
163+
about a CR that was parsed from a file. *)
133164
type t [@@deriving equal, sexp_of]
134165

135166
(** {1 Getters} *)
136167

137168
val path : t -> Vcs.Path_in_repo.t
138169

139170
(** [content] is the text of the CR with comment markers removed from the
140-
beginning and end (if applicable). *)
171+
beginning and end (if applicable). See also {!reindented_content}. *)
141172
val content : t -> string
142173

143174
(** [whole_loc] is suitable for removal of the entire CR comment. It includes
@@ -146,12 +177,19 @@ val whole_loc : t -> Loc.t
146177

147178
val header : t -> Header.t Or_error.t
148179
val kind : t -> Kind.t
180+
181+
(** [due t] is a convenience wrapper to get the [due] property of the CR
182+
header. This returns [Now] when parsing the header resulted in an error. *)
149183
val due : t -> Due.t
184+
185+
(** [work_on t] represents the expectation as to when work on the CR is meant to
186+
happen. Is it similar to [due t] except that XCRs are meant to be worked
187+
on [Now]. *)
150188
val work_on : t -> Due.t
151189

152190
(** This digest is computed such that changes in positions in a file, or changes
153191
in whitespaces are ignored. It is used by downstream systems to detect
154-
that two crs are equivalent, which in turn may affect when a cr is
192+
that two CRs are equivalent, which in turn may affect when a CR is
155193
active. *)
156194
val digest_ignoring_minor_text_changes : t -> Digest_hex.t
157195

@@ -160,13 +198,12 @@ val digest_ignoring_minor_text_changes : t -> Digest_hex.t
160198
(** Show the CR with a line showing the file position. *)
161199
val to_string : t -> string
162200

163-
(** [reindented_content t] is similar to {!content}, but reseting the
164-
indentation of the actual CR to a normalized amount, to print multiple CRs
165-
together in a more unified fashion. This is used by [crs grep] for
166-
example. *)
201+
(** [reindented_content t] returns the content of the CR with leading
202+
indentation removed or normalized. This is useful for displaying multiple
203+
CRs together in a unified format, such as in [crs grep]. *)
167204
val reindented_content : t -> string
168205

169-
(** Sorts the supplied list of crs and outputs it to the supplied out channel,
206+
(** Sorts the supplied list of CRs and outputs it to the supplied out channel,
170207
separated by newline characters. *)
171208
val output_list : t list -> oc:Out_channel.t -> unit
172209

@@ -185,11 +222,11 @@ val sort : t list -> t list
185222
186223
This module is exported to be used by libraries with strong ties to
187224
[cr_comment]. Its signature may change in breaking ways at any time without
188-
prior notice, and outside of the guidelines set by semver.
225+
prior notice, and outside the guidelines set by semver.
189226
190-
In particular, the intention here is that cr comments may only be created
191-
using dedicated helpers libraries that are defined in this project, parsing
192-
comments from files in vcs trees. *)
227+
In particular, the intention here is that CRs may only be created using
228+
dedicated helpers libraries that are defined in this project, parsing them
229+
from files in vcs trees. *)
193230

194231
module Private : sig
195232
type header := Header.t

lib/crs_cli/src/crs_cli.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let main =
2424
~summary:"A tool for managing code review comments embedded in source code."
2525
~readme:(fun () ->
2626
{|
27-
The primary goal of $(b,crs) is to make it easy to locate, parse, and manipulate special code review comments called 'CRs' (pronouned "C"-"R"-z), embedded directly in source code.
27+
The primary goal of $(b,crs) is to make it easy to locate, parse, and manipulate special code review comments called 'CRs' (pronounced "C"-"R"-z), embedded directly in source code.
2828

2929
This CLI aims to offer ergonomic helpers for tasks such as systematically updating comments across multiple files, changing their priority, marking them as resolved, modifying reporter or assignee information, and more.
3030

lib/crs_cli/src/crs_cli.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121

2222
val main : unit Command.t
2323

24+
(** {1 Private}
25+
26+
This module is exported to be used by libraries with strong ties to [crs].
27+
Its signature may change in breaking ways at any time without prior notice,
28+
and outside of the guidelines set by semver. *)
29+
2430
module Private : sig
2531
val grep_cmd : unit Command.t
2632
end

lib/crs_parser/src/crs_parser.mli

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,26 @@
4646
* - Use [Vcs] instead of [Hg].
4747
*)
4848

49-
(** This pattern is exposed to speed up the extraction of CR comments across a
50-
repository. First we do an over estimation of files that may contain comments
51-
using this pattern, and then parse them with this module. *)
52-
val cr_pattern_egrep : string
49+
(** Utils for parsing and searching for code review comments (CRs) in versioned
50+
source files. *)
5351

54-
(** Parse all comments from a file. Comments that look like cr but are somewhat
55-
invalid are still returned as errors, so we can alert the user rather than
56-
simply ignoring them. *)
52+
(** {1 Parsing} *)
53+
54+
(** Parse all code review comments (CRs) from a file. Comments that resemble CRs
55+
but are malformed or partially invalid are still returned, with error
56+
information in their metadata, so users can be alerted rather than having
57+
such comments silently ignored. *)
5758
val parse_file
5859
: path:Vcs.Path_in_repo.t
5960
-> file_contents:Vcs.File_contents.t
6061
-> Cr_comment.t list
6162

63+
(** {1 Searching} *)
64+
65+
(** Search recursively for all code review comments (CRs) in files versioned
66+
under the supplied [repo_root], starting at and [below] the given path in
67+
the repository. Only files tracked by the version control system are
68+
included; untracked or ignored files are skipped. Returns all found CRs. *)
6269
val grep
6370
: vcs:< Vcs.Trait.ls_files ; .. > Vcs.t
6471
-> repo_root:Vcs.Repo_root.t

lib/crs_parser/src/file_parser.mli

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@
5151
* - Remove assignee computation (left as external work).
5252
*)
5353

54-
val cr_pattern_egrep : string
55-
5654
val parse_file
5755
: path:Vcs.Path_in_repo.t
5856
-> file_contents:Vcs.File_contents.t
5957
-> Cr_comment.t list
58+
59+
(** This pattern is exposed to speed up the extraction of CR comments across a
60+
repository. First we do an over estimation of files that may contain comments
61+
using this pattern, and then parse them with this module.
62+
63+
It is defined in this file so it is next to other related regexps, but it is
64+
actually used in [crs_parser.ml]. *)
65+
val cr_pattern_egrep : string

0 commit comments

Comments
 (0)