Skip to content

Commit fe3420f

Browse files
Merge pull request #928 from MisterDA/odoc
Documentation fixes: cross-refs, internal links
2 parents 3885cf7 + 380f957 commit fe3420f

15 files changed

+273
-319
lines changed

CHANGES

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
* On Windows, make Lwt_process.create_process duplicate standard handles given to the child process if they're not inheritable, to mimic the behaviour of Unix.create_process. (#909, Antonin Décimo)
1616
* Add missing dependency to `cppo` in lwt-react's opam file. (#946, Rizo I)
17+
* Improve documentation (especially internal links). (#928, Antonin Décimo)
1718

1819
====== Fixes ======
1920

2021
* Fix win32_spawn leaking dev_null fd in the parent process. (#906, Antonin Décimo)
2122
* Prefer SetHandleInformation to DuplicateHandle in set_close_on_exec for sockets. DuplicateHandle mustn't be used on sockets. (#907, Antonin Décimo)
22-
* Lwt.pick and Lwt.choose select preferentially failed promises as per
23-
documentation (#856, #874, Raman Varabets)
23+
* Lwt.pick and Lwt.choose select preferentially failed promises as per documentation (#856, #874, Raman Varabets)
2424
* Use the WSA_FLAG_NO_HANDLE_INHERIT on Windows when creating sockets with WSASocket if the cloexec (non-inheritable) parameter is true. Fixes a Windows problem where a child process would inherit a supposedly non-inheritable socket. (#910, Antonin Décimo)
2525
* Fix macOS/arm64 tests which have a 16k page. (#932, Kate Deplaix)
2626

src/core/lwt.mli

Lines changed: 93 additions & 105 deletions
Large diffs are not rendered by default.

src/core/lwt_mvar.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
(** Mailbox variables *)
3030

31-
(** "Mailbox" variables implement a synchronising variable, used for
31+
(** Mailbox variables implement a synchronising variable, used for
3232
communication between concurrent threads. *)
3333

3434
type 'a t

src/core/lwt_pqueue.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
(** Functional priority queues (deprecated).
77
88
A priority queue maintains, in the abstract sense, a set of elements in
9-
order, and supports fast lookup and removal of the first ("minimum")
9+
order, and supports fast lookup and removal of the first (minimum)
1010
element. This is used in Lwt for organizing threads that are waiting for
1111
timeouts.
1212
13-
The priority queues in this module preserve "duplicates": elements that
13+
The priority queues in this module preserve duplicates: elements that
1414
compare equal in their order.
1515
1616
@deprecated This module is an internal implementation detail of Lwt, and may

src/core/lwt_stream.mli

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ val create : unit -> 'a t * ('a option -> unit)
4545
(** [create ()] returns a new stream and a push function.
4646
4747
To notify the stream's consumer of errors, either use a separate
48-
communication channel, or use a
49-
{{:https://ocaml.org/api/Stdlib.html#TYPEresult}
50-
[result]} stream. There is no way to push an exception into a
51-
push-stream. *)
48+
communication channel, or use a {!Stdlib.result} stream. There is
49+
no way to push an exception into a push-stream. *)
5250

5351
val create_with_reference : unit -> 'a t * ('a option -> unit) * ('b -> unit)
5452
(** [create_with_reference ()] returns a new stream and a push
@@ -78,22 +76,22 @@ class type ['a] bounded_push = object
7876
(** Change the size of the stream queue. Note that the new size
7977
can smaller than the current stream queue size.
8078
81-
It raises [Invalid_argument] if [size < 0]. *)
79+
It raises {!Stdlib.Invalid_argument} if [size < 0]. *)
8280

8381
method push : 'a -> unit Lwt.t
8482
(** Pushes a new element to the stream. If the stream is full then
8583
it will block until one element is consumed. If another thread
86-
is already blocked on {!push}, it raises {!Full}. *)
84+
is already blocked on [push], it raises {!Lwt_stream.Full}. *)
8785

8886
method close : unit
89-
(** Closes the stream. Any thread currently blocked on {!push}
90-
fails with {!Closed}. *)
87+
(** Closes the stream. Any thread currently blocked on
88+
{!Lwt_stream.bounded_push.push} fails with {!Lwt_stream.Closed}. *)
9189

9290
method count : int
9391
(** Number of elements in the stream queue. *)
9492

9593
method blocked : bool
96-
(** Is a thread is blocked on {!push} ? *)
94+
(** Is a thread is blocked on {!Lwt_stream.bounded_push.push} ? *)
9795

9896
method closed : bool
9997
(** Is the stream closed ? *)
@@ -238,11 +236,7 @@ val junk_while_s : ('a -> bool Lwt.t) -> 'a t -> unit Lwt.t
238236

239237
val junk_old : 'a t -> unit Lwt.t
240238
(** [junk_old st] removes all elements that are ready to be read
241-
without yielding from [st].
242-
243-
For example, the [read_password] function of [Lwt_read_line]
244-
uses it to flush keys previously typed by the user.
245-
*)
239+
without yielding from [st]. *)
246240

247241
val get_available : 'a t -> 'a list
248242
(** [get_available st] returns all available elements of [l] without
@@ -397,7 +391,11 @@ val hexdump : char t -> string t
397391
Basically, here is a simple implementation of [hexdump -C]:
398392
399393
{[
400-
let () = Lwt_main.run (Lwt_io.write_lines Lwt_io.stdout (Lwt_stream.hexdump (Lwt_io.read_lines Lwt_io.stdin)))
394+
let () = Lwt_main.run begin
395+
Lwt_io.write_lines
396+
Lwt_io.stdout
397+
(Lwt_stream.hexdump (Lwt_io.read_lines Lwt_io.stdin))
398+
end
401399
]}
402400
*)
403401

src/react/lwt_react.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module E : sig
3131
val next : 'a event -> 'a Lwt.t
3232
(** [next e] returns the next occurrence of [e].
3333
34-
Avoid trying to create an "asynchronous loop" by calling [next e] again in
34+
Avoid trying to create an asynchronous loop by calling [next e] again in
3535
a callback attached to the promise returned by [next e]:
3636
3737
- The callback is called within the React update step, so calling [next e]
@@ -40,7 +40,7 @@ module E : sig
4040
- If you instead arrange for the React update step to end (for example, by
4141
calling [Lwt.pause ()] within the callback), multiple React update steps
4242
may occur before the callback calls [next e] again, so some occurrences
43-
can be effectively "lost."
43+
can be effectively lost.
4444
4545
To robustly asynchronously process occurrences of [e] in a loop, use
4646
[to_stream e], and repeatedly call {!Lwt_stream.next} on the resulting
@@ -66,7 +66,7 @@ module E : sig
6666
value is available on the stream.
6767
6868
If updating the event causes an exception at any point during the update
69-
step, the excpetion is passed to [!]{!Lwt.async_exception_hook}, which
69+
step, the exception is passed to [!]{!Lwt.async_exception_hook}, which
7070
terminates the process by default. *)
7171

7272
val delay : 'a event Lwt.t -> 'a event

src/unix/config/discover.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ struct
463463
linking with -lpthread fails. So, try to link the test code without
464464
any flags first.
465465
466-
If that fails and we are not targetting Android, try to link with
466+
If that fails and we are not targeting Android, try to link with
467467
-lpthread. If *that* fails, search for libpthread in the filesystem.
468468
469-
When targetting Android, compiling without -lpthread is the only way
469+
When targeting Android, compiling without -lpthread is the only way
470470
to link with pthread, and we don't to search for libpthread, because
471471
if we find it, it is likely the host's libpthread. *)
472472
match compiles context code with

src/unix/lwt_engine.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class libev : ?backend:Ev_backend.t -> unit -> object
144144
(** Returns [loop]. *)
145145
end
146146

147-
(** Engine based on [Unix.select]. *)
147+
(** Engine based on {!Unix.select}. *)
148148
class select : t
149149

150150
(** Abstract class for engines based on a select-like function. *)

src/unix/lwt_fmt.mli

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,21 @@
77
88
@since 4.1.0 *)
99

10-
(** This module bridges the gap between
11-
{{:https://ocaml.org/api/Format.html} [Format]}
12-
and {!Lwt}. Although it is not required, it is recommended to use this
13-
module with the {{:http://erratique.ch/software/fmt} [Fmt]} library.
10+
(** This module bridges the gap between {!Stdlib.Format} and {!Lwt}.
11+
Although it is not required, it is recommended to use this module
12+
with the {{:http://erratique.ch/software/fmt} [Fmt]} library.
1413
1514
Compared to regular formatting function, the main difference is that
1615
printing statements will now return promises instead of blocking.
1716
*)
1817

1918
val printf : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a
2019
(** Returns a promise that prints on the standard output.
21-
Similar to
22-
{{:https://ocaml.org/api/Format.html#VALprintf}
23-
[Format.printf]}. *)
20+
Similar to {!Stdlib.Format.printf}. *)
2421

2522
val eprintf : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a
2623
(** Returns a promise that prints on the standard error.
27-
Similar to
28-
{{:https://ocaml.org/api/Format.html#VALeprintf}
29-
[Format.eprintf]}. *)
24+
Similar to {!Stdlib.Format.eprintf}. *)
3025

3126
(** {1 Formatters} *)
3227

@@ -55,16 +50,14 @@ val stderr : formatter
5550
val make_formatter :
5651
commit:(unit -> unit Lwt.t) -> fmt:Format.formatter -> unit -> formatter
5752
(** [make_formatter ~commit ~fmt] creates a new lwt formatter based on the
58-
{{:https://ocaml.org/api/Format.html#TYPEformatter}
59-
[Format.formatter]} [fmt]. The [commit] function will be called by the
53+
{!Stdlib.Format.formatter} [fmt]. The [commit] function will be called by the
6054
printing functions to update the underlying channel.
6155
*)
6256

6357
val get_formatter : formatter -> Format.formatter
64-
(** [get_formatter fmt] returns the underlying
65-
{{:https://ocaml.org/api/Format.html#TYPEformatter}
66-
[Format.formatter]}. To access the underlying formatter during printing, it
67-
isvrecommended to use [%t] and [%a].
58+
(** [get_formatter fmt] returns the underlying {!Stdlib.Format.formatter}.
59+
To access the underlying formatter during printing, it
60+
is recommended to use [%t] and [%a].
6861
*)
6962

7063
(** {2 Printing} *)
@@ -82,10 +75,8 @@ val ikfprintf :
8275
formatter -> ('b, Format.formatter, unit, 'a) format4 -> 'b
8376

8477
val flush : formatter -> unit Lwt.t
85-
(** [flush fmt] flushes the formatter (as with
86-
{{:https://ocaml.org/api/Format.html#VALpp_print_flush}
87-
[Format.pp_print_flush]}) and
88-
executes all the printing action on the underlying channel.
78+
(** [flush fmt] flushes the formatter (as with {!Stdlib.Format.pp_print_flush})
79+
and executes all the printing action on the underlying channel.
8980
*)
9081

9182

src/unix/lwt_io.mli

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Note about errors: input functions of this module raise
2929
[End_of_file] when the end-of-file is reached (i.e. when the read
3030
function returns [0]). Other exceptions are ones caused by the
31-
backend read/write functions, such as [Unix.Unix_error].
31+
backend read/write functions, such as {!Unix.Unix_error}.
3232
*)
3333

3434
exception Channel_closed of string
@@ -118,7 +118,7 @@ val make :
118118
@param close close function of the channel. It defaults to
119119
[Lwt.return]
120120
121-
@param seek same meaning as [Unix.lseek]
121+
@param seek same meaning as {!Unix.lseek}
122122
123123
@param mode either {!input} or {!output}
124124
@@ -275,17 +275,15 @@ val read_into_exactly_bigstring : input_channel -> Lwt_bytes.t -> int -> int ->
275275

276276
val read_value : input_channel -> 'a Lwt.t
277277
(** [read_value channel] reads a marshaled value from [channel]; it corresponds
278-
to the standard library's
279-
{{:https://ocaml.org/api/Marshal.html#VALfrom_channel} [Marshal.from_channel]}.
280-
The corresponding writing function is {!write_value}.
278+
to the standard library's {!Stdlib.Marshal.from_channel}. The corresponding
279+
writing function is {!write_value}.
281280
282281
Note that reading marshaled values is {e not}, in general, type-safe. See
283-
the warning in the description of module
284-
{{:https://ocaml.org/api/Marshal.html}
285-
[Marshal]} for details. The short version is: if you read a value of one
286-
type, such as [string], when a value of another type, such as [int] has
287-
actually been marshaled to [channel], you may get arbitrary behavior,
288-
including segmentation faults, access violations, security bugs, etc. *)
282+
the warning in the description of module {!Stdlib.Marshal} for details. The
283+
short version is: if you read a value of one type, such as [string], when a
284+
value of another type, such as [int] has actually been marshaled to
285+
[channel], you may get arbitrary behavior, including segmentation faults,
286+
access violations, security bugs, etc. *)
289287

290288
(** {2 Writing} *)
291289

@@ -336,9 +334,8 @@ val write_from_string_exactly :
336334
val write_value :
337335
output_channel -> ?flags : Marshal.extern_flags list -> 'a -> unit Lwt.t
338336
(** [write_value channel ?flags v] writes [v] to [channel] using the [Marshal]
339-
module of the standard library. See
340-
{{:https://ocaml.org/api/Marshal.html#VALto_channel}
341-
[Marshal.to_channel]} for an explanation of [?flags].
337+
module of the standard library. See {!Stdlib.Marshal.to_channel} for an
338+
explanation of [?flags].
342339
343340
The corresponding reading function is {!read_value}. See warnings about type
344341
safety in the description of {!read_value}. *)
@@ -421,8 +418,7 @@ val open_file :
421418
If [~buffer] is supplied, it is used as the I/O buffer.
422419
423420
If [~flags] is supplied, the file is opened with the given flags (see
424-
{{: https://ocaml.org/api/Unix.html#TYPEopen_flag}
425-
[Unix.open_flag]}). Note that [~flags] is used {e exactly} as given. For
421+
{!Unix.open_flag}). Note that [~flags] is used {e exactly} as given. For
426422
example, opening a file with [~flags] and [~mode:Input] does {e not}
427423
implicitly add [O_RDONLY]. So, you should include [O_RDONLY] when opening
428424
for reading ([~mode:Input]), and [O_WRONLY] when opening for writing
@@ -436,7 +432,7 @@ val open_file :
436432
Note: if opening for writing ([~mode:Output]), and the file already exists,
437433
[open_file] truncates (clears) the file by default. If you would like to
438434
keep the pre-existing contents of the file, use the [~flags] parameter to
439-
pass a custom flags list that does not include [Unix.O_TRUNC].
435+
pass a custom flags list that does not include {!Unix.O_TRUNC}.
440436
441437
@raise Unix.Unix_error on error. *)
442438

@@ -482,12 +478,9 @@ val open_temp_file :
482478
file.
483479
484480
[?temp_dir] can be used to choose the directory in which the file is
485-
created. For the current directory, use
486-
{{: https://ocaml.org/api/Filename.html#VALcurrent_dir_name}
487-
[Filename.current_dir_name]}. If not specified, the directory is taken from
488-
{{: https://ocaml.org/api/Filename.html#VALget_temp_dir_name}
489-
[Filename.get_temp_dir_name]}, which is typically set to your system
490-
temporary file directory.
481+
created. For the current directory, use {!Stdlib.Filename.current_dir_name}.
482+
If not specified, the directory is taken from {!Stdlib.Filename.get_temp_dir_name},
483+
which is typically set to your system temporary file directory.
491484
492485
[?prefix] helps determine the name of the file. It will be the prefix
493486
concatenated with a random sequence of characters. If not specified,
@@ -739,7 +732,7 @@ type byte_order = Lwt_sys.byte_order = Little_endian | Big_endian
739732
(** Type of byte order *)
740733

741734
val system_byte_order : byte_order
742-
(** Same as {!Lwt_sys.byte_order}. *)
735+
(** Same as {!val:Lwt_sys.byte_order}. *)
743736

744737
(** {2 Low-level access to the internal buffer} *)
745738

@@ -768,7 +761,7 @@ type direct_access = {
768761
}
769762

770763
val direct_access : 'a channel -> (direct_access -> 'b Lwt.t) -> 'b Lwt.t
771-
(** [direct_access ch f] passes to [f] a {!direct_access}
764+
(** [direct_access ch f] passes to [f] a {!type:direct_access}
772765
structure. [f] must use it and update [da_ptr] to reflect how
773766
many bytes have been read/written. *)
774767

@@ -782,7 +775,7 @@ val set_default_buffer_size : int -> unit
782775
(** Change the default buffer size.
783776
784777
@raise Invalid_argument if the given size is smaller than [16]
785-
or greater than [Sys.max_string_length] *)
778+
or greater than {!Stdlib.Sys.max_string_length} *)
786779

787780
(** {2 Deprecated} *)
788781

0 commit comments

Comments
 (0)