package odoc

  1. Overview
  2. Docs
OCaml documentation generator

Install

dune-project
 Dependency

Authors

Maintainers

Sources

odoc-2.1.1.tbz
sha256=f574dbd28cd0fc3a2b95525c4bb95ddf6d1f6408bb4fe12157fa537884f987fd
sha512=1c545c281a7022a167f028fff8cec6fb3f2f82da0881431be74e7a4281c5353ed83bfbdb4d9d9e08af6755dbe3505c052c5e5b58cdeb08c57aed5e89c0f15e91

doc/src/odoc.manpage/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
open Odoc_document

let for_printing url = List.map snd @@ Url.Path.to_list url

let segment_to_string (kind, name) =
  match kind with
  | `Module | `Page | `LeafPage | `Class -> name
  | _ -> Format.asprintf "%a-%s" Odoc_document.Url.Path.pp_kind kind name

let as_filename (url : Url.Path.t) =
  let components = Url.Path.to_list url in
  let dir, path =
    Url.Path.split
      ~is_dir:(function `Page -> `IfNotLast | _ -> `Never)
      components
  in
  let dir = List.map segment_to_string dir in
  let path = String.concat "." (List.map segment_to_string path) in
  let str_path = String.concat Fpath.dir_sep (dir @ [ path ]) in
  Fpath.(v str_path + ".3o")

let rec is_class_or_module_path (url : Url.Path.t) =
  match url.kind with
  | `Module | `LeafPage | `Page | `Class -> (
      match url.parent with
      | None -> true
      | Some url -> is_class_or_module_path url)
  | _ -> false

let should_inline x = not @@ is_class_or_module_path x

let files_of_url url =
  if is_class_or_module_path url then [ as_filename url ] else []