package odoc
OCaml Documentation Generator
Install
Dune Dependency
Authors
Maintainers
Sources
odoc-3.1.0.tbz
sha256=355b3cfff4934903cbaed8b51ce35e333e8609932d230294200a9f2d42ffa914
sha512=f78318d0a16164a9cd16ee02f611c2e00d32b772fe38e992d6db6ec94b1c00cd9c377fbfe64031b8f245e57b2f3aac9364108327e7f1693533ddcff94c476e05
doc/src/odoc.odoc_utils/odoc_utils.ml.html
Source file odoc_utils.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
type msg = [ `Msg of string ] (** The [result] type and a bind operator. This module is meant to be opened. *) module ResultMonad = struct let map_error f = function Ok _ as ok -> ok | Error e -> Error (f e) let of_option ~error = function Some x -> Ok x | None -> Error error let ( >>= ) = Result.bind end (** A bind operator for the [option] type. This module is meant to be opened. *) module OptionMonad = struct (* The error case become [None], the error value is ignored. *) let of_result = function Ok x -> Some x | Error _ -> None let ( >>= ) = Option.bind end module List = Odoc_list module Tree = Tree module Forest = Tree.Forest module Json = Json module Io_utils = struct (** [with_open_*] are resource safe wrappers around opening and closing channels. They are equivalent to the same functions in OCaml 4.14's [In_channel] and [Out_channel]. *) let _with_resource res ~close f = Fun.protect ~finally:(fun () -> close res) (fun () -> f res) let with_open_in fname f = _with_resource (open_in fname) ~close:close_in_noerr f let with_open_in_bin fname f = _with_resource (open_in_bin fname) ~close:close_in_noerr f (** Read a file line-by-line by folding [f]. *) let fold_lines fname f acc = _with_resource (open_in fname) ~close:close_in_noerr (fun ic -> let rec loop acc = match input_line ic with | exception End_of_file -> acc | line -> loop (f line acc) in loop acc) (** Read a file as a list of lines. *) let read_lines fname = List.rev (fold_lines fname (fun line acc -> line :: acc) []) let with_open_out fname f = _with_resource (open_out fname) ~close:close_out_noerr f let with_open_out_bin fname f = _with_resource (open_out_bin fname) ~close:close_out_noerr f (** Like [with_open_out] but operate on a [Format] buffer. *) let with_formatter_out fname f = with_open_out fname (fun oc -> f (Format.formatter_of_out_channel oc)) (** Shortcuts for composing [with_open_*] functions and [Marshal]. *) let marshal fname v = with_open_out_bin fname (fun oc -> Marshal.to_channel oc v []) let unmarshal fname = with_open_in_bin fname Marshal.from_channel end module Int = struct include Int let max x y : t = if x >= y then x else y end include Astring
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>