• 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

64.29
/src/model/comment.ml
1
module Path = Paths.Path
2
module Reference = Paths.Reference
3
module Identifier = Paths.Identifier
4

5
type 'a with_location = 'a Location_.with_location
6

7
type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ]
8

9
type alignment = [ `Left | `Center | `Right ]
10

11
type raw_markup_target = string
12

13
type leaf_inline_element =
14
  [ `Space
15
  | `Word of string
16
  | `Code_span of string
17
  | `Math_span of string
18
  | `Raw_markup of raw_markup_target * string ]
19

20
type non_link_inline_element =
21
  [ leaf_inline_element
22
  | `Styled of style * non_link_inline_element with_location list ]
23

24
(* The cross-referencer stores section heading text, and sometimes pastes it
25
   into link contents. This type alias is provided for use by the
26
   cross-referencer. *)
27
type link_content = non_link_inline_element with_location list
28

29
type reference_element = [ `Reference of Reference.t * link_content ]
30

31
type inline_element =
32
  [ leaf_inline_element
33
  | `Styled of style * inline_element with_location list
34
  | reference_element
35
  | `Link of string * link_content ]
36

37
type paragraph = inline_element with_location list
38

39
type module_reference = {
40
  module_reference : Reference.Module.t;
41
  module_synopsis : paragraph option;
42
}
43
(** The [{!modules: ...}] markup. [module_synopsis] is initially [None], it is
44
    resolved during linking. *)
45

46
type 'a cell = 'a with_location list * [ `Header | `Data ]
47
type 'a row = 'a cell list
48
type 'a grid = 'a row list
49

50
type 'a abstract_table = {
51
  data : 'a grid;
52
  align : alignment option list option;
53
}
54

55
type nestable_block_element =
56
  [ `Paragraph of paragraph
57
  | `Code_block of
58
    string option
59
    * string with_location
60
    * nestable_block_element with_location list option
61
  | `Math_block of string
62
  | `Verbatim of string
63
  | `Modules of module_reference list
64
  | `Table of nestable_block_element abstract_table
65
  | `List of
66
    [ `Unordered | `Ordered ] * nestable_block_element with_location list list
67
  ]
68

69
type tag =
70
  [ `Author of string
71
  | `Deprecated of nestable_block_element with_location list
72
  | `Param of string * nestable_block_element with_location list
73
  | `Raise of
74
    [ `Code_span of string | reference_element ]
75
    * nestable_block_element with_location list
76
  | `Return of nestable_block_element with_location list
77
  | `See of
78
    [ `Url | `File | `Document ]
79
    * string
80
    * nestable_block_element with_location list
81
  | `Since of string
82
  | `Before of string * nestable_block_element with_location list
83
  | `Version of string
84
  | `Alert of string * string option ]
85

86
type heading_level =
87
  [ `Title
88
  | `Section
89
  | `Subsection
90
  | `Subsubsection
91
  | `Paragraph
92
  | `Subparagraph ]
93

94
type attached_block_element = [ nestable_block_element | `Tag of tag ]
95

96
type heading_attrs = {
97
  heading_level : heading_level;
98
  heading_label_explicit : bool;
99
      (** Whether the label have been written by the user. *)
100
}
101

102
type block_element =
103
  [ nestable_block_element
104
  | `Heading of
105
    heading_attrs * Identifier.Label.t * inline_element with_location list
106
  | `Tag of tag ]
107

108
type docs = block_element with_location list
109

110
type docs_or_stop = [ `Docs of docs | `Stop ]
111

112
(** The synopsis is the first element of a comment if it is a paragraph.
113
    Otherwise, there is no synopsis. *)
114
let synopsis = function
115
  | { Location_.value = `Paragraph p; _ } :: _ -> Some p
559✔
116
  | _ -> None
2,094✔
117

118
let rec link_content_of_inline_element :
119
    inline_element with_location -> link_content =
120
 fun x ->
121
  let v = x.Location_.value in
278✔
122
  match v with
123
  | #leaf_inline_element as e -> [ { x with value = e } ]
278✔
124
  | `Reference (_, r) -> r
×
125
  | `Link (_, l) -> l
×
126
  | `Styled (st, elems) ->
×
127
      [ { x with value = `Styled (st, link_content_of_inline_elements elems) } ]
×
128

129
and link_content_of_inline_elements l =
130
  l |> List.map link_content_of_inline_element |> List.concat
82✔
131

132
let find_zero_heading docs : link_content option =
133
  List.find_map
41✔
134
    (fun doc ->
135
      match doc.Location_.value with
41✔
136
      | `Heading ({ heading_level = `Title; _ }, _, h_content) ->
41✔
137
          Some (link_content_of_inline_elements h_content)
41✔
NEW
138
      | _ -> None)
×
139
    docs
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