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

ocaml / odoc / 2168

10 Jul 2024 02:38PM UTC coverage: 71.437% (-0.4%) from 71.864%
2168

Pull #1142

github

web-flow
Merge 9bc2c3b35 into de54ed266
Pull Request #1142: Parsing of path-references to pages and modules

68 of 127 new or added lines in 6 files covered. (53.54%)

700 existing lines in 17 files now uncovered.

9794 of 13710 relevant lines covered (71.44%)

3534.91 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 t =
33
    | Page of string
34
    | Compilation_unit of compilation_unit
35
    | Impl of string
36

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

41
  let create_page name = Page name
35✔
42

43
  let create_impl name = Impl name
31✔
44

45
  let name = function
UNCOV
46
    | Page name | Compilation_unit { name; _ } | Impl name -> name
×
47

48
  let hidden = function
UNCOV
49
    | Page _ | Impl _ -> false
×
50
    | Compilation_unit m -> m.hidden
148✔
51
end
52

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

59
let equal : t -> t -> bool = ( = )
60

61
let hash : t -> int = Hashtbl.hash
62

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

89
  Format.asprintf "%a" pp t.id
90

UNCOV
91
let compare x y = String.compare x.digest y.digest
×
92

93
module Hash_table = Hashtbl.Make (struct
94
  type nonrec t = t
95

96
  let equal = equal
97

98
  let hash = hash
99
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