Skip to content

Commit 35cf29d

Browse files
committed
Output katex support files in support-files CLI
1 parent c6e64f4 commit 35cf29d

File tree

18 files changed

+533
-42
lines changed

18 files changed

+533
-42
lines changed

.ocamlformat-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ src/loader/cmti.ml
66
src/loader/doc_attr.ml
77
src/loader/*.cppo.ml
88
src/model/*.cppo.ml
9+
src/vendor/*.ml
910
test/xref2/lib/*

doc/dune

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
(documentation
22
(package odoc)
3-
(mld_files contributing driver dune features index interface
4-
ocamldoc_differences odoc_for_authors parent_child_spec))
3+
(mld_files
4+
contributing
5+
driver
6+
dune
7+
features
8+
index
9+
interface
10+
ocamldoc_differences
11+
odoc_for_authors
12+
parent_child_spec))
513

614
(rule
715
(alias docgen)

doc/examples/dune

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
(public_name odoc.examples)
44
(enabled_if
55
(> %{ocaml_version} 4.11))
6-
(modules_without_implementation expansion resolution unexposed wrapping
7-
markup))
6+
(modules_without_implementation
7+
expansion
8+
resolution
9+
unexposed
10+
wrapping
11+
markup))

doc/library_mlds/dune

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
(documentation
22
(package odoc)
3-
(mld_files odoc_document odoc_examples odoc_html odoc_latex odoc_loader
4-
odoc_manpage odoc_model odoc_model_desc odoc_odoc odoc_xref2
5-
odoc_xref_test))
3+
(mld_files
4+
odoc_document
5+
odoc_examples
6+
odoc_html
7+
odoc_latex
8+
odoc_loader
9+
odoc_manpage
10+
odoc_model
11+
odoc_model_desc
12+
odoc_odoc
13+
odoc_xref2
14+
odoc_xref_test))

dune-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
(lang dune 2.7)
1+
(lang dune 3.0)
22
(name odoc)
33
(cram enable)

odoc.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ depends: [
4343

4444
"ppx_expect" {with-test}
4545
"bos" {with-test}
46+
"crunch" {with-test}
4647

4748
("ocaml" {< "4.07.0" & with-test} | "bisect_ppx" {with-test & > "2.5.0"})
4849
("ocaml" {< "4.03.0" & with-test} | "mdx" {with-test})

src/odoc/dune

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
(library
22
(name odoc_odoc)
33
(public_name odoc.odoc)
4-
(libraries compiler-libs.common fpath odoc_html odoc_manpage odoc_latex
5-
odoc_loader odoc_model odoc_xref2 tyxml unix)
4+
(libraries
5+
compiler-libs.common
6+
fpath
7+
odoc_html
8+
odoc_manpage
9+
odoc_latex
10+
odoc_vendor
11+
odoc_loader
12+
odoc_model
13+
odoc_xref2
14+
tyxml
15+
unix)
616
(instrumentation
717
(backend bisect_ppx)))
818

@@ -21,18 +31,6 @@
2131
(cat %{css})
2232
(echo "|css}")))))
2333

24-
(rule
25-
(targets highlight_js.ml)
26-
(deps
27-
(:js ../vendor/highlight.pack.js))
28-
(action
29-
(with-stdout-to
30-
%{targets}
31-
(progn
32-
(echo "let content = {js|")
33-
(cat %{js})
34-
(echo "|js}")))))
35-
3634
; Install theme files for odig.
3735

3836
(install

src/odoc/support_files.ml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
let iter_files f ?(without_theme = false) output_directory =
22
let file name content =
3-
let name =
4-
Fs.File.create ~directory:output_directory ~name |> Fs.File.to_string
5-
in
3+
let name = Fs.File.create ~directory:output_directory ~name in
64
f name content
75
in
8-
96
if not without_theme then file "odoc.css" Css_file.content;
10-
file "highlight.pack.js" Highlight_js.content
7+
let files = Odoc_vendor.file_list in
8+
List.iter
9+
(fun f ->
10+
match Odoc_vendor.read f with
11+
| Some content -> file f content
12+
| None -> ())
13+
files
1114

1215
let write =
1316
iter_files (fun name content ->
17+
let dir = Fs.File.dirname name in
18+
Fs.Directory.mkdir_p dir;
19+
let name = Fs.File.to_string name in
1420
let channel = open_out name in
1521
output_string channel content;
1622
close_out channel)
1723

18-
let print_filenames = iter_files (fun name _content -> print_endline name)
24+
let print_filenames =
25+
iter_files (fun name _content -> print_endline (Fs.File.to_string name))

src/vendor/dune

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(rule
2+
(alias runtest)
3+
(deps
4+
(:x odoc_vendor.ml)
5+
(glob_files *.js)
6+
(glob_files *.css)
7+
(glob_files_rec *.woff2))
8+
(action
9+
(progn
10+
(setenv
11+
SOURCE_DATE_EPOCH
12+
0
13+
(run ocaml-crunch . -e js -e css -e woff2 -o %{x}.corrected -m plain -s))
14+
(diff? %{x} %{x}.corrected))))
15+
16+
(library
17+
(name odoc_vendor)
18+
(public_name odoc.vendor)
19+
(wrapped false))

src/vendor/odoc_vendor.ml

Lines changed: 393 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)