Merge branch 'jshighlight'
Ralf Treinen
3 years ago
0 | 0 | Author: Ralf Treinen <treinen@debian.org> |
1 | 1 | Description: removed vendored highlight js library. |
2 | The file odoc/support_files.ml is patched so that, instead of | |
3 | creating a copy of the support files, creates symbolic links. | |
2 | Instead of using the content of the vendored js library, it uses | |
3 | highlight.min.js from the libjs-highlight.js package | |
4 | 4 | |
5 | Index: ocaml-odoc/src/odoc/dune | |
6 | =================================================================== | |
7 | --- ocaml-odoc.orig/src/odoc/dune 2020-04-23 19:36:22.436878628 +0200 | |
8 | +++ ocaml-odoc/src/odoc/dune 2020-04-23 19:36:22.436878628 +0200 | |
9 | @@ -14,29 +14,8 @@ | |
5 | --- a/src/odoc/dune | |
6 | +++ b/src/odoc/dune | |
7 | @@ -26,17 +26,16 @@ | |
10 | 8 | |
11 | (documentation) | |
9 | (rule | |
10 | (targets highlight_js.ml) | |
11 | - (deps (:js ../vendor/highlight.pack.js)) | |
12 | +; (deps (:js ../vendor/highlight.pack.js)) | |
13 | (action | |
14 | (with-stdout-to %{targets} | |
15 | (progn | |
16 | (echo "let content = {js|") | |
17 | - (cat %{js}) | |
18 | +; (cat %{js}) | |
19 | (echo "|js}"))))) | |
12 | 20 | |
13 | -(rule | |
14 | - (targets css_file.ml) | |
15 | - (deps (:css etc/odoc.css)) | |
16 | - (action | |
17 | - (with-stdout-to %{targets} | |
18 | - (progn | |
19 | - (echo "let content = {css|") | |
20 | - (cat %{css}) | |
21 | - (echo "|css}"))))) | |
22 | - | |
23 | -(rule | |
24 | - (targets highlight_js.ml) | |
25 | - (deps (:js ../vendor/highlight.pack.js)) | |
26 | - (action | |
27 | - (with-stdout-to %{targets} | |
28 | - (progn | |
29 | - (echo "let content = {js|") | |
30 | - (cat %{js}) | |
31 | - (echo "|js}"))))) | |
32 | - | |
33 | 21 | ; Install theme files for odig. |
34 | 22 | (install |
35 | 23 | (section share) |
37 | 25 | - (etc/odoc.css as odoc-theme/default/odoc.css) |
38 | 26 | - (../vendor/highlight.pack.js as odoc-theme/default/highlight.pack.js))) |
39 | 27 | + (etc/odoc.css as odoc-theme/default/odoc.css))) |
40 | Index: ocaml-odoc/src/odoc/support_files.ml | |
41 | =================================================================== | |
42 | --- ocaml-odoc.orig/src/odoc/support_files.ml 2020-04-23 19:36:22.436878628 +0200 | |
43 | +++ ocaml-odoc/src/odoc/support_files.ml 2020-04-23 19:38:38.729590833 +0200 | |
44 | @@ -1,23 +1,19 @@ | |
45 | let iter_files f ?(without_theme = false) output_directory = | |
46 | - let file name content = | |
47 | + let file name target = | |
48 | let name = | |
49 | Fs.File.create ~directory:output_directory ~name | |
50 | |> Fs.File.to_string | |
51 | in | |
52 | - f name content | |
53 | + f name target | |
28 | --- a/src/odoc/support_files.ml | |
29 | +++ b/src/odoc/support_files.ml | |
30 | @@ -7,10 +7,19 @@ let iter_files f ?(without_theme = false | |
31 | f name content | |
54 | 32 | in |
55 | 33 | |
34 | + let highlight_js_content = | |
35 | + let ic = open_in "/usr/share/javascript/highlight.js/highlight.min.js" in | |
36 | + let n = in_channel_length ic in | |
37 | + let s = Bytes.create n in | |
38 | + really_input ic s 0 n; | |
39 | + close_in ic; | |
40 | + (Bytes.unsafe_to_string s) | |
41 | + in | |
42 | + | |
56 | 43 | if not without_theme then begin |
57 | - file "odoc.css" Css_file.content | |
58 | + file "odoc.css" "/usr/share/odoc/odoc-theme/default/odoc.css" | |
44 | file "odoc.css" Css_file.content | |
59 | 45 | end; |
60 | 46 | - file "highlight.pack.js" Highlight_js.content |
61 | + file "highlight.pack.js" "/usr/share/javascript/highlight.js/highlight.min.js" | |
47 | + file "highlight.pack.js" highlight_js_content | |
62 | 48 | |
63 | 49 | let write = |
64 | - iter_files begin fun name content -> | |
65 | - let channel = open_out name in | |
66 | - output_string channel content; | |
67 | - close_out channel | |
68 | - end | |
69 | + iter_files (fun name target -> Unix.symlink target name) | |
70 | ||
71 | let print_filenames = | |
72 | - iter_files (fun name _content -> print_endline name) | |
73 | + iter_files (fun name _target -> print_endline name) | |
50 | iter_files begin fun name content -> |