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

ocaml / odoc / 1820

17 Jan 2024 01:21PM CUT coverage: 56.493% (+0.01%) from 56.482%
1820

push

github

panglesd
When generating a hidden module, mention why it is empty.

Signed-off-by: Paul-Elliot <peada@free.fr>

7104 of 12575 relevant lines covered (56.49%)

819.95 hits per line

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

0.0
/src/html/html_fragment_json.ml
1
(* Rendering of HTML fragments together with metadata. For embedding the
2
   generated documentation in existing websites.
3
*)
4

5
module Html = Tyxml.Html
6
module Url = Odoc_document.Url
7

8
let json_of_breadcrumbs (breadcrumbs : Types.breadcrumb list) : Utils.Json.json
9
    =
10
  let breadcrumb (b : Types.breadcrumb) =
×
11
    `Object
×
12
      [
13
        ("name", `String b.name);
14
        ("href", `String b.href);
15
        ("kind", `String (Url.Path.string_of_kind b.kind));
×
16
      ]
17
  in
18
  let json_breadcrumbs = breadcrumbs |> List.map breadcrumb in
19
  `Array json_breadcrumbs
×
20

21
let json_of_toc (toc : Types.toc list) : Utils.Json.json =
22
  let rec section (s : Types.toc) =
×
23
    `Object
×
24
      [
25
        ("title", `String s.title_str);
26
        ("href", `String s.href);
27
        ("children", `Array (List.map section s.children));
×
28
      ]
29
  in
30
  let toc_json_list = toc |> List.map section in
31
  `Array toc_json_list
×
32

33
let make ~config ~preamble ~url ~breadcrumbs ~toc ~uses_katex ~source_anchor
34
    content children =
35
  let filename = Link.Path.as_filename ~is_flat:(Config.flat config) url in
×
36
  let filename = Fpath.add_ext ".json" filename in
×
37
  let htmlpp = Html.pp_elt ~indent:(Config.indent config) () in
×
38
  let json_to_string json = Utils.Json.to_string json in
×
39
  let source_anchor =
40
    match source_anchor with Some url -> `String url | None -> `Null
×
41
  in
42
  let content ppf =
43
    Format.pp_print_string ppf
×
44
      (json_to_string
×
45
         (`Object
46
           [
47
             ("type", `String "documentation");
48
             ("uses_katex", `Bool uses_katex);
49
             ("breadcrumbs", json_of_breadcrumbs breadcrumbs);
×
50
             ("toc", json_of_toc toc);
×
51
             ("source_anchor", source_anchor);
52
             ( "preamble",
53
               `String
54
                 (String.concat ""
×
55
                    (List.map (Format.asprintf "%a" htmlpp) preamble)) );
×
56
             ( "content",
57
               `String
58
                 (String.concat ""
×
59
                    (List.map (Format.asprintf "%a" htmlpp) content)) );
×
60
           ]))
61
  in
62
  { Odoc_document.Renderer.filename; content; children }
63

64
let make_src ~config ~url ~breadcrumbs content =
65
  let filename = Link.Path.as_filename ~is_flat:(Config.flat config) url in
×
66
  let filename = Fpath.add_ext ".json" filename in
×
67
  let htmlpp = Html.pp_elt ~indent:(Config.indent config) () in
×
68
  let json_to_string json = Utils.Json.to_string json in
×
69
  let content ppf =
70
    Format.pp_print_string ppf
×
71
      (json_to_string
×
72
         (`Object
73
           [
74
             ("type", `String "source");
75
             ("breadcrumbs", json_of_breadcrumbs breadcrumbs);
×
76
             ( "content",
77
               `String
78
                 (String.concat ""
×
79
                    (List.map (Format.asprintf "%a" htmlpp) content)) );
×
80
           ]))
81
  in
82
  { Odoc_document.Renderer.filename; content; children = [] }
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

© 2025 Coveralls, Inc