Source file ag_doc.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

type inline =
    [ `Text of string
    | `Code of string ]
type block = [ `Paragraph of inline list | `Pre of string ]
type doc = [ `Text of block list ]

let parse_text loc s =
  try Some (Some (`Text (Ag_doc_lexer.parse_string s : block list)))
  with e ->
    failwith (Printf.sprintf "%s:\nInvalid format for doc.text %S:\n%s"
                (Atd_ast.string_of_loc loc) s (Printexc.to_string e))

let get_doc loc an : doc option =
  Atd_annot.get_field (parse_text loc) None ["doc"] "text" an