package drom_lib

  1. Overview
  2. Docs

Source file odoc.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
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2020 OCamlPro & Origin Labs                               *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

open Types
open EzCompat

let subst ?(more = fun v -> Printf.sprintf "${%s}" v) package s =
  let b = Buffer.create (2 * String.length s) in
  Buffer.add_substitute b
    (function
      | "name" -> package.name
      | "pack" -> Misc.library_module package
      | "synopsis" -> Misc.p_synopsis package
      | "description" -> Misc.p_description package
      | "modules" -> String.concat " " (Misc.modules package)
      | v -> more v)
    s;
  Buffer.contents b

(*
let template_src_index_mld p =
  match p.kind with
  | Virtual -> assert false
  | Library ->
    (* TODO: we should check pack-modules: if it is false, we have to
       find all the modules in the directory and generate a link
       for each module. *)
    if Misc.p_pack_modules p then
      Some
        (subst p
           {|
{1 Library ${name}}

${description}

The entry point of this library is the module: {!${pack}}.
|})
    else
      Some
        (subst p
           {|
{1 Library ${name}}

${description}

This library exposes the following toplevel modules:
{!modules:${modules}}
|})
  | Program -> Some (subst p {|
{1 Program ${name}}

${description}
|})
*)
OCaml

Innovation. Community. Security.