• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ocaml / odoc / 2072

10 Jun 2024 10:09AM UTC coverage: 71.986% (+0.2%) from 71.774%
2072

Pull #1145

github

web-flow
Merge 1b7b0910b into 1ced6f23f
Pull Request #1145: "Global" Sidebar

195 of 220 new or added lines in 12 files covered. (88.64%)

630 existing lines in 13 files now uncovered.

9834 of 13661 relevant lines covered (71.99%)

3561.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.05
/src/model/root.ml
1
(*
2
 * Copyright (c) 2014 Leo White <leo@lpw25.net>
3
 *
4
 * Permission to use, copy, modify, and distribute this software for any
5
 * purpose with or without fee is hereby granted, provided that the above
6
 * copyright notice and this permission notice appear in all copies.
7
 *
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 *)
16

17
module Package = struct
18
  type t = string
19

20
  module Table = Hashtbl.Make (struct
21
    type nonrec t = t
22

23
    let equal : t -> t -> bool = ( = )
24

25
    let hash : t -> int = Hashtbl.hash
26
  end)
27
end
28

29
module Odoc_file = struct
30
  type compilation_unit = { name : string; hidden : bool }
31

32
  type page = { name : string; title : Comment.link_content option }
33

34
  type t =
35
    | Page of page
36
    | Compilation_unit of compilation_unit
37
    | Impl of string
38

39
  let create_unit ~force_hidden name =
40
    let hidden = force_hidden || Names.contains_double_underscore name in
1✔
41
    Compilation_unit { name; hidden }
42

43
  let create_page name title = Page { name; title }
42✔
44

45
  let create_impl name = Impl name
31✔
46

47
  let name = function
NEW
48
    | Page { name; _ } | Compilation_unit { name; _ } | Impl name -> name
×
49

50
  let hidden = function
51
    | Page _ | Impl _ -> false
×
52
    | Compilation_unit m -> m.hidden
142✔
53
end
54

55
type t = {
56
  id : Paths.Identifier.OdocId.t;
57
  file : Odoc_file.t;
58
  digest : Digest.t;
59
}
60

61
let equal : t -> t -> bool = ( = )
62

63
let hash : t -> int = Hashtbl.hash
64

65
let to_string t =
66
  let rec pp fmt (id : Paths.Identifier.OdocId.t) =
×
67
    match id.iv with
×
68
    | `SourcePage (parent, name) ->
×
69
        let rec loop_pp fmt parent =
70
          match parent.Paths.Identifier.iv with
×
71
          | `SourceDir (p, name) -> Format.fprintf fmt "%a::%s" loop_pp p name
×
72
          | `Page _ as iv -> Format.fprintf fmt "%a" pp { parent with iv }
×
73
        in
74
        Format.fprintf fmt "%a::%s" loop_pp parent name
75
    | `LeafPage (parent, name) | `Page (parent, name) -> (
×
76
        match parent with
77
        | Some p ->
×
78
            Format.fprintf fmt "%a::%a" pp
79
              (p :> Paths.Identifier.OdocId.t)
80
              Names.PageName.fmt name
81
        | None -> Format.fprintf fmt "%a" Names.PageName.fmt name)
×
82
    | `Root (Some parent, name) ->
×
83
        Format.fprintf fmt "%a::%a" pp
84
          (parent :> Paths.Identifier.OdocId.t)
85
          Names.ModuleName.fmt name
86
    | `Root (None, name) -> Format.fprintf fmt "%a" Names.ModuleName.fmt name
×
87
    | `Implementation name ->
×
88
        Format.fprintf fmt "impl(%a)" Names.ModuleName.fmt name
89
  in
90

91
  Format.asprintf "%a" pp t.id
92

93
let compare x y = String.compare x.digest y.digest
×
94

95
module Hash_table = Hashtbl.Make (struct
96
  type nonrec t = t
97

98
  let equal = equal
99

100
  let hash = hash
101
end)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc