package odoc
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
OCaml documentation generator
Install
dune-project
Dependency
Authors
Maintainers
Sources
odoc-2.1.1.tbz
sha256=f574dbd28cd0fc3a2b95525c4bb95ddf6d1f6408bb4fe12157fa537884f987fd
sha512=1c545c281a7022a167f028fff8cec6fb3f2f82da0881431be74e7a4281c5353ed83bfbdb4d9d9e08af6755dbe3505c052c5e5b58cdeb08c57aed5e89c0f15e91
doc/src/odoc.html/link.ml.html
Source file link.ml
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96module Url = Odoc_document.Url let flat = ref false (* Translation from Url.Path *) module Path = struct let for_printing url = List.map snd @@ Url.Path.to_list url let segment_to_string (kind, name) = match kind with | `Module | `Page -> name | _ -> Format.asprintf "%a-%s" Url.Path.pp_kind kind name let is_leaf_page url = url.Url.Path.kind = `LeafPage let get_dir_and_file url = let l = Url.Path.to_list url in let is_dir = if !flat then function `Page -> `Always | _ -> `Never else function `LeafPage -> `Never | `File -> `Never | _ -> `Always in let dir, file = Url.Path.split ~is_dir l in let dir = List.map segment_to_string dir in let file = match file with | [] -> "index.html" | [ (`LeafPage, name) ] -> name ^ ".html" | [ (`File, name) ] -> name | xs -> assert !flat; String.concat "-" (List.map segment_to_string xs) ^ ".html" in (dir, file) let for_linking url = let dir, file = get_dir_and_file url in dir @ [ file ] let as_filename (url : Url.Path.t) = Fpath.(v @@ String.concat Fpath.dir_sep @@ for_linking url) end let semantic_uris = ref false type resolve = Current of Url.Path.t | Base of string let rec l1 l2 = match (l1, l2) with | l1 :: l1s, l2 :: l2s when l1 = l2 -> drop_shared_prefix l1s l2s | _, _ -> (l1, l2) let href ~resolve t = let { Url.Anchor.page; anchor; _ } = t in let target_loc = Path.for_linking page in (* If xref_base_uri is defined, do not perform relative URI resolution. *) match resolve with | Base xref_base_uri -> ( let page = xref_base_uri ^ String.concat "/" target_loc in match anchor with "" -> page | anchor -> page ^ "#" ^ anchor) | Current path -> ( let current_loc = Path.for_linking path in let current_from_common_ancestor, target_from_common_ancestor = drop_shared_prefix current_loc target_loc in let relative_target = match current_from_common_ancestor with | [] -> (* We're already on the right page *) (* If we're already on the right page, the target from our common ancestor can't be anything other than the empty list *) assert (target_from_common_ancestor = []); [] | [ _ ] -> (* We're already in the right dir *) target_from_common_ancestor | l -> (* We need to go up some dirs *) List.map (fun _ -> "..") (List.tl l) @ target_from_common_ancestor in let remove_index_html l = match List.rev l with | "index.html" :: rest -> List.rev ("" :: rest) | _ -> l in let relative_target = if !semantic_uris then remove_index_html relative_target else relative_target in match (relative_target, anchor) with | [], "" -> "#" | page, "" -> String.concat "/" page | page, anchor -> String.concat "/" page ^ "#" ^ anchor)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>