File: support_files.ml

package info (click to toggle)
ocaml-odoc 1.5.2%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 5,972 kB
  • sloc: ml: 26,974; makefile: 59; sh: 35
file content (32 lines) | stat: -rw-r--r-- 824 bytes parent folder | download
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
let iter_files f ?(without_theme = false) output_directory =
  let file name content =
    let name =
      Fs.File.create ~directory:output_directory ~name
      |> Fs.File.to_string
    in
    f name content
  in

  let highlight_js_content =
    let ic = open_in "/usr/share/javascript/highlight.js/highlight.min.js" in
    let n = in_channel_length ic in
    let s = Bytes.create n in
    really_input ic s 0 n;
    close_in ic;
    (Bytes.unsafe_to_string s)
  in

  if not without_theme then begin
    file "odoc.css" Css_file.content
  end;
  file "highlight.pack.js" highlight_js_content

let write =
  iter_files begin fun name content ->
    let channel = open_out name in
    output_string channel content;
    close_out channel
  end

let print_filenames =
  iter_files (fun name _content -> print_endline name)