this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix docsite sidebar rendering, CSS theming, and support file deployment

- Fix sidebar kindBadge: map leaf-page→pg, module-type→MT, etc. (was
showing "L" for leaf-page entries)
- Stop escaping sidebar content HTML (entries contain <code> tags)
- Fix inline sidebar JSON: use Html.cdata_script instead of Html.txt
to prevent HTML-escaping inside <script> tags
- Add --xo-* CSS custom properties for x-ocaml cells in light/dark themes
- Fix support file registration: use 'opam var share' instead of
'opam var x-ocaml:share' (works without x-ocaml being an opam package)
- Suppress empty <li> from config-only extension tags (@x-ocaml.*)
- Add worker_url field to jtw opam findlib_index.json
- Refactor x-ocaml.js worker URL discovery to support both direct
worker_url and day10-style version/content_hash paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+34 -20
+34 -20
src/x_ocaml.ml
··· 60 60 if status = 200 then Some (Jv.to_string (Jv.get xhr "responseText")) 61 61 else None 62 62 63 - (** Extract compiler version and content_hash from a findlib_index.json. 63 + (** Parse the compiler object from findlib_index.json. 64 64 Uses browser JSON.parse — no OCaml JSON library needed. *) 65 - let compiler_from_findlib_index = 65 + let findlib_index_json = 66 66 match findlib_index_url with 67 67 | None -> None 68 68 | Some url -> ··· 70 70 | None -> None 71 71 | Some text -> 72 72 (try 73 - let json = Jv.call (Jv.get Jv.global "JSON") "parse" [| Jv.of_string text |] in 74 - let compiler = Jv.get json "compiler" in 75 - if Jv.is_none compiler || Jv.is_undefined compiler then None 76 - else 73 + Some (Jv.call (Jv.get Jv.global "JSON") "parse" [| Jv.of_string text |]) 74 + with _ -> None) 75 + 76 + let findlib_index_base_dir = 77 + match findlib_index_url with 78 + | None -> "" 79 + | Some fi_url -> 80 + match String.rindex_opt fi_url '/' with 81 + | Some i -> String.sub fi_url 0 (i + 1) 82 + | None -> fi_url 83 + 84 + (** Derive the worker URL from findlib_index.json's compiler field. 85 + Supports two modes: 86 + - Direct: compiler.worker_url (relative to findlib_index.json) 87 + - Day10-style: compiler.version + compiler.content_hash constructs 88 + ../../../compiler/{version}/{content_hash}/worker.js *) 89 + let worker_url_from_findlib_index = 90 + match findlib_index_json with 91 + | None -> None 92 + | Some json -> 93 + let compiler = Jv.get json "compiler" in 94 + if Jv.is_none compiler || Jv.is_undefined compiler then None 95 + else 96 + let worker_url = Jv.get compiler "worker_url" in 97 + if not (Jv.is_none worker_url || Jv.is_undefined worker_url) then 98 + Some (findlib_index_base_dir ^ Jv.to_string worker_url) 99 + else 100 + try 77 101 let version = Jv.to_string (Jv.get compiler "version") in 78 102 let content_hash = Jv.to_string (Jv.get compiler "content_hash") in 79 - Some (version, content_hash) 80 - with _ -> None) 103 + Some (findlib_index_base_dir ^ "../../../compiler/" ^ version ^ "/" ^ content_hash ^ "/worker.js") 104 + with _ -> None 81 105 82 106 let worker_url = 83 107 (* Priority: 1) explicit x-ocaml-worker meta tag, ··· 86 110 match read_meta "x-ocaml-worker" with 87 111 | Some url -> url 88 112 | None -> 89 - match compiler_from_findlib_index with 90 - | Some (version, content_hash) -> 91 - (* Construct worker URL relative to the findlib_index's directory. 92 - findlib_index is at e.g. .../p/yojson/3.0.0/findlib_index.json 93 - We need .../compiler/<ver>/<hash>/worker.js 94 - Relative from the findlib_index dir: ../../../compiler/... *) 95 - let fi_url = Option.get findlib_index_url in 96 - let base_dir = match String.rindex_opt fi_url '/' with 97 - | Some i -> String.sub fi_url 0 (i + 1) 98 - | None -> fi_url 99 - in 100 - base_dir ^ "../../../compiler/" ^ version ^ "/" ^ content_hash ^ "/worker.js" 113 + match worker_url_from_findlib_index with 114 + | Some url -> url 101 115 | None -> 102 116 match current_attribute "src-worker" with 103 117 | None ->