Source file print_table.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
(****************************************************************************)
(*  print-table - Simple Unicode/ANSI and Markdown text table rendering     *)
(*  SPDX-FileCopyrightText: 2025 Mathieu Barbin <mathieu.barbin@gmail.com>  *)
(*  SPDX-License-Identifier: ISC                                            *)
(****************************************************************************)

type t = Print_table_ast.t

let to_string_text = Print_table_text.to_string
let to_string_markdown = Print_table_markdown.to_string

module Style = struct
  include Print_table_ast.Style

  let default = Default
  let fg_green = Fg_green
  let fg_red = Fg_red
  let fg_yellow = Fg_yellow
  let dim = Dim
  let underscore = Underscore
end

module Cell = struct
  include Print_table_ast.Cell

  let empty = { style = Style.default; text = "" }
  let is_empty t = String.length t.text = 0
  let text ?(style = Style.default) text = { style; text }
end

module Align = struct
  include Print_table_ast.Align
end

module Column = struct
  include Print_table_ast.Column

  let make ~header ?(align = Align.Left) make_cell = { header; align; make_cell }
end

let make ~columns ~rows = Print_table_ast.T { columns; rows }

module O = struct
  module Align = Align
  module Cell = Cell
  module Column = Column
  module Style = Style
end

module Private = struct
  module Ast = Print_table_ast

  let to_ast t = t
end