File: doc_comments.mli

package info (click to toggle)
ocamlformat 0.28.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,436 kB
  • sloc: ml: 63,321; pascal: 4,769; lisp: 229; sh: 217; makefile: 121
file content (663 lines) | stat: -rw-r--r-- 14,437 bytes parent folder | download | duplicates (2)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
(** Manpages. See {!Cmdliner.Manpage}. *)

type block =
  [ `S of string
  | `P of string
  | `Pre of string
  | `I of string * string
  | `Noblank
  | `Blocks of block list ]

include M with type t := t
(** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod *)

val escape : string -> string
(** [escape s] escapes [s] from the doc language. *)

type title = string * int * string * string * string

(** {1:standard-section-names Standard section names} *)

val s_name : string

(** {1:section-maps Section maps}

    Used for handling the merging of metadata doc strings. *)

type smap

val smap_append_block : smap -> sec:string -> block -> smap
(** [smap_append_block smap sec b] appends [b] at the end of section [sec]
    creating it at the right place if needed. *)

(** {1:content-boilerplate Content boilerplate} *)

val s_environment_intro : block

(** {1:output Output} *)

type format = [`Auto | `Pager | `Plain | `Groff]

val print :
     ?errs:Format.formatter
  -> ?subst:(string -> string option)
  -> format
  -> Format.formatter
  -> t
  -> unit

(** {1:printers-and-escapes-used-by-cmdliner-module Printers and escapes
    used by Cmdliner module} *)

val subst_vars :
     errs:Format.formatter
  -> subst:(string -> string option)
  -> Buffer.t
  -> string
  -> string
(** [subst b ~subst s], using [b], substitutes in [s] variables of the form
    "$(doc)" by their [subst] definition. This leaves escapes and markup
    directives $(markup,...) intact.

    @raise Invalid_argument in case of illegal syntax. *)

val doc_to_plain :
     errs:Format.formatter
  -> subst:(string -> string option)
  -> Buffer.t
  -> string
  -> string
(** [doc_to_plain b ~subst s] using [b], subsitutes in [s] variables by
    their [subst] definition and renders cmdliner directives to plain text.

    @raise Invalid_argument in case of illegal syntax. *)

val k : k
(** this is a comment

    @author foo

    @author Foooooooooooooooooooooooooooooooooooo Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar

    @version foo

    @version Foooooooooooooooooooooooooooooooooooo Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar

    @see <foo> foo

    @see <https://slash-create.js.org/#/docs/main/latest/class/SlashCreator?scrollTo=registerCommandsIn> this url is very long

    @since foo

    @since Foooooooooooooooooooooooooooooooooooo.Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar

    @before foo [foo]

    @before Foooooooooooooooooooooooooooooooooooo.Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar Foo bar

    @deprecated [foo]

    @deprecated Foooooooooooooooooooooooooooooooooooo Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar Foo bar

    @param foo [foo]

    @param Foooooooooooooo_Baaaaaaaaaaaaar Fooooooooooo foooooooooooo fooooooooooo baaaaaaaaar

    @param Foooooooooooooooooooooooooooooooooooo_baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar Foo bar

    @raise foo [foo]

    @raise Foooooooooooooooooooooooooooooooooooo_baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar Foo bar

    @return [foo]

    @inline

    @canonical foo

    @canonical Foooooooooooooooooooooooooooooooooooo.Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar *)

val x : x
(** a comment

    @version foo *)

(** Managing Chunks.

    This module exposes functors to store raw contents into append-only
    stores as chunks of same size. It exposes the {{!AO} AO} functor which
    split the raw contents into [Data] blocks, addressed by [Node] blocks.
    That's the usual rope-like representation of strings, but chunk trees
    are always build as perfectly well-balanced and blocks are addressed by
    their hash (or by the stable keys returned by the underlying store).

    A chunk has the following structure:

    {v
    --------------------------      --------------------------
    | uint8_t type            |     | uint8_t type            |
    ---------------------------     ---------------------------
    | uint16_t                |     | uint64_t                |
    ---------------------------     ---------------------------
    | key children[length]    |     | byte data[length]       |
    ---------------------------     ---------------------------
    v}

    [type] is either [Data] (0) or [Index] (1). If the chunk contains data,
    [length] is the payload length. Otherwise it is the number of children
    that the node has.

    It also exposes {{!AO_stable} AO_stable} which -- as {{!AO} AO} does --
    stores raw contents into chunks of same size. But it also preserves the
    nice properpty that values are addressed by their hash. instead of by
    the hash of the root chunk node as it is the case for {{!AO} AO}. *)

(** This is verbatim:

    {v
   o  o
  /\  /\
  /\  /\
    v}

    This is preformated code:

    {[
let verbatim s =
  s |> String.split_lines |> List.map ~f:String.strip
  |> fun s -> list s "@," Fmt.str
    ]} *)

(** Lists:

    list with short lines:

    - x
    - y
    - z

    list with long lines:

    - xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
      xxx xxx xxx xxx xxx xxx xxx
    - yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy
      yyy yyy yyy yyy yyy yyy yyy
    - zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
      zzz zzz zzz zzz zzz zzz zzz

    enumerated list with long lines:

    + xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
      xxx xxx xxx xxx xxx xxx xxx
    + yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy yyy
      yyy yyy yyy yyy yyy yyy yyy
    + zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz
      zzz zzz zzz zzz zzz zzz zzz

    list with sub lists:

    {ul
     {- xxx

        - a
        - b
        - c
     }
     {- yyy

        + a
        + b
        + c
     }} *)

(** {{:https://github.com/} Github} *)

(** {:https://github.com/} *)

(** An array index offset: [exp1\[exp2\]] *)

(** to extend \{foo syntax *)

(** The different forms of references in \@see tags. *)

(** Printf groff string for the \@before information. *)

(** [a]'c [b]'s [c]'c *)

(** return true if [\gamma(lhs) \subseteq \gamma(rhs)] *)

(** Composition of functions: [(f >> g) x] is exactly equivalent to
    [g (f (x))]. Left associative. *)

(** [†] [Struct_rec] is *)

(** for [Global]s *)

(** generic command: ∀xs.[foot]-[post] *)

(** A *)
val foo : int -> unit
(** B *)

(** C *)

(** A *)
val foo : int -> unit
(** B *)

module Foo : sig
  (** A *)
  val foo : int -> unit
  (** B *)

  (** C *)

  (** A *)
  val foo : int -> unit
  (** B *)
end

(** [\[ \] \[\] \]] *)

(** \{ \} \[ \] \@ \@ *)

(** @canonical Foo *)

(** @canonical Module.Foo.Bar *)

(** {v
a
    v} *)

(** {[
b
    ]} *)

(** - Odoc don't parse

    multiple paragraph in a list *)

(** {ul
     {- Abc

        Def
     }
     {- Hij
     }
     {- Klm

        {ul
         {- Nop

            Qrs
         }
         {- Tuv
         }}
     }} *)

(** - {v
    Abc
    def
      v}
    - {[
A
  B
      ]} *)

(** Code block
    {[ Single line ]}
    {[
      Multi
      line
    ]}
    {[
      Multi
      line
        with
          indentation
    ]}
    {[ Single long line HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ]}
    {[
      With empty

      line
    ]}
    {[ First line
       on the same line
       as opening ]}
 *)

module X :
sig

  (** {[ First line
         on the same line
         as opening ]} *)

end

(** {!module:A} {!module:A.B}

    {!module-type:A} {!module-type:A.b}

    {!class:c} {!class:M.c}

    {!class-type:c} {!class-type:M.c}

    {!val:x} {!val:M.x}

    {!type:t} {!type:M.t}

    {!exception:E} {!exception:M.E}

    {!method:m} {!method:c.m}

    {!constructor:C} {!constructor:M.C}

    {!field:f} {!field:t.f} {!field:M.t.f}
 *)

(** {!modules:Foo}

    {!modules:Foo Bar.Baz}

    @canonical Foo

    @canonical Foo.Bar
*)

(** {%html:<p>Raw markup</p>%} {%Without language%} {%other:Other language%} *)

(** [Multi
     Line]

    [ A lot of    spaces ]

    [Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] *)

(** {[
  for i = 1 to 3
  do
    Printf.printf "let x%d = %d\n" i i
  done
]} *)

(** {[
  print_newline ();
  List.iter
    (fun s -> Printf.printf "let ( %s ) = Pervasives.( %s )\n" s s)
    ["+"; "-"; "*"; "/"]
]}  *)

(** {[
  #use "import.cinaps";;

  List.iter all_fields ~f:(fun (name, type_) -> printf "\nexternal get_%s
  : unit -> %s = \"get_%s\"" name type_ name)
]} *)

(** {[


  List.iter all_fields ~f:(fun (name, type_) -> printf "\nexternal get_%s
  : unit -> %s = \"get_%s\"" name type_ name)
]} *)

(** {[
  let x = 1 in

  (* fooooooo *)
  let y = 2 in
  (* foooooooo *)
  z
]} *)

(** {[
   let this  = is_short
]}

{[
  does not parse: verbatim
+/+/+ /+/+/ +/+//+/+/+/+/+/+/+/
+/+/+ /+/+/ +/+//+/+/+/+/+/+/+/
+/+/+ /+/+/ +/+//+/+/+/+/+/+/+/
+/+/+ /+/+/ +/+//+/+
]}

{[
[@@@ocamlformat "break-separators = after"]

let fooooooooooooooooo =
[ foooooooooooooooooooooooooooooooo
; foooooooooooooooooooooooooooooooo
; foooooooooooooooooooooooooooooooo ]

]}

{[
let fooooooooooooooooo =
[ foooooooooooooooooooooooooooooooo
; foooooooooooooooooooooooooooooooo
; foooooooooooooooooooooooooooooooo ]

]} *)



(**
  This is a comment with code inside
  {[
    (** This is a comment with code inside
        [ let code inside = f inside ]
    *)
    let code inside (* comment   *) = f inside
  ]}

  Code block with metadata:
  {@ocaml[ code ]}

  {@ocaml kind=toplevel[ code ]}

  {@ocaml kind=toplevel env=e1[
    (** This is a comment with code inside
        [ let code inside = f inside ]
    *)
    let code inside (* comment   *) = f inside
  ]}
*)

(** {e foooooooo oooooooooo ooooooooo ooooooooo} {i fooooooooooooo oooooooo oooooooooo} {b fooooooooooooo oooooooooooo oooooo ooooooo} *)

(** {e foooooooo oooooooooo ooooooooo ooooooooo} {{!some ref} fooooooooooooo
    oooooooo oooooooooo} {b fooooooooooooo oooooooooooo oooooo ooooooo} *)

(** foooooooooooooooooooooooooooooooooooooooooooooooooo foooooooooooo {b eee + eee eee} *)

(** foooooooooooooooooooooooooooooooooooooooooooooooooo foooooooooooooooo {b + eee + eee eee} *)

val f : int

(***)

val k : int

(**)

(** {e foooooooo oooooooooo ooooooooo ooooooooo
       {i fooooooooooooo oooooooo oooooooooo
          {b fooooooooooooo oooooooooooo oooooo ooooooo}}} *)

(** {e
       {i fooooooooooooo oooooooo oooooooooo
          {b fooooooooooooo oooooooooooo oooooo ooooooo}} foooooooo
       oooooooooo ooooooooo ooooooooo} *)

(** foooooooooo fooooooooooo

    {e foooooooo oooooooooo ooooooooo ooooooooo
       {i fooooooooooooo oooooooo oooooooooo
          {b fooooooooooooo oooooooooooo oooooo ooooooo}} fooooooooooooo
       foooooooooo fooooo
       {i fooooooooooooo oooooooo oooooooooo
          {b fooooooooooooo oooooooooooo oooooo ooooooo}}}

    {e foooooooo oooooooooo ooooooooo ooooooooo
       {i fooooooooooooo oooooooo oooooooooo}}

    fooooooooooooo foooooooooooooo:

    - foo
    - {e foooooooo oooooooooo ooooooooo ooooooooo
         {i fooooooooooooo oooooooo oooooooooo}}
    - {e foooooooo oooooooooo ooooooooo ooooooooo}
      {i fooooooooooooo oooooooo oooooooooo}
    - foo *)

(** Brackets must not be escaped in the first argument of some tags: *)

(** @raise [Invalid_argument] if the argument is [None]. Sometimes [t.[x]]. *)

(** @author [Abc] [def] \[hij\] *)

(** @author {Abc} {def} \{hij\} *)

(** @param [id] [def] \[hij\] *)

(** @raise [exn] [def] \[hij\] *)

(** @since [Abc] [def] \[hij\] *)

(** @before [Abc] [def] \[hij\] *)

(** @version [Abc] [def] \[hij\] *)

(** @see <[Abc]> [def] \[hij\] *)

(** @see '[Abc]' [def] \[hij\] *)

(** @see "[Abc]" [def] \[hij\] *)

(** \[abc\] *)
(** *)
(**  *)

(** [trim "  "] is [""] *)

(** [trms (c × (Σᵢ₌₁ⁿ cᵢ × Πⱼ₌₁ᵐᵢ Xᵢⱼ^pᵢⱼ))]
    is the sequence of terms [Xᵢⱼ] for each [i] and [j]. *)

(**

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi lacinia odio sit amet lobortis fringilla. Mauris diam massa, vulputate sit amet lacus id, vestibulum bibendum lectus. Nullam tristique justo nisi, gravida dapibus mi pulvinar at. Suspendisse pellentesque odio quis ipsum tempor luctus.

Cras ultrices, magna sit amet faucibus molestie, sapien dolor ullamcorper lorem, vel viverra tortor augue vel massa. Suspendisse nunc nisi, consequat et ante nec, efficitur dapibus ipsum. Aenean vitae pellentesque odio. Integer et ornare tellus, at tristique elit.

Phasellus et nisi id neque ultrices vestibulum vitae non tortor. Mauris aliquet at risus sed rhoncus. Ut condimentum rhoncus orci, sit amet eleifend erat tempus quis.

*)

(** {[(* a
         b *)]} *)

val a :
  fooooooooooooooooooooooooooo
  (** {[(* a
           b *)]} *)
  ->
  fooooooooooooooooooooooooo

type x =
  { a : t
  (** {[(* a
           b *)]} *)
  ; b : [` A
  (** {[(* a
           b *)]} *) ]
  }

type x =
  | A of a
  (** {[(* a
           b *)]} *)
  | B of b
  (** {[(* a
           b *)]} *)

(** Set a different language name in the block metadata to not format as OCaml:

    {@sh[ echo "this""is""only""a""single"(echo word)(echo also) ]} *)

(**a*)(**b*)

(** Inline math: {m \infty}

    Inline math elements can wrap as well {m \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty \infty} or {m \f\relax{x} = \int_{-\infty}^\infty \f\hat\xi\,e^{2 \pi i \xi x} \,d\xi}.

    Block math:

    {math \infty}

    {math
    \infty
    }

    {math

    \pi

    }

    {math

    \infty

   \pi

       \pi

    \pi

    }

    {math {m \f\relax{x} = \int_{-\infty}^\infty \f\hat\xi\,e^{2 \pi i \xi x} \,d\xi}}

    {math
    % \f is defined as #1f(#2) using the macro
    \f\relax{x} = \int_{-\infty}^\infty
    \f\hat\xi\,e^{2 \pi i \xi x}
    \,d\xi
    }
*)

(** {[
     let _ = {|
        Doc-comment contains code blocks that contains string with breaks and
        ending with trailing spaces.
       |}
   ]} *)

(** ISO-Latin1 characters in identifiers
    {[ω]}*)

(** Here, [my_list=[]]. *)

(** Here, [my_list=\[\]]. *)

(** This code block will change due to the brackets being re-escaped.
    [ [ \[ [] ] ]. *)

(** at@ *)
(** \@at *)

(** Lists can't be nested
    - foo
    - module system documentation including
    {ol
    {- bar}
    {- baz}
    }
*)

(** Space before a reference or link text is preserved. A newline is turned
    into a space. {{!ref}
    with newline} and {{!ref} with space}. *)