Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #24: representation extensions; provides a plotting extension: scatterplots, line plots, decision boundaries etc. #47

Merged
merged 25 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aadc4e7
Fixes #24: support independent representation extensions
lukstafi Sep 25, 2024
bf2f467
Remove registering backends for extensibility; fix: stop caching
lukstafi Sep 25, 2024
f0ec8ab
Plotting 1 of 3: text only, no nesting
lukstafi Sep 25, 2024
4d52d22
Expose `PrintBox_ext_plot.concise_float`
lukstafi Sep 25, 2024
e40afd3
Partially rendered boxes: embed rendering result in a box
lukstafi Sep 25, 2024
381d59c
Plotting in html: mimic the text rendering
lukstafi Sep 25, 2024
3cef520
Plotting extension: html output
lukstafi Sep 26, 2024
da5fbce
Uniform interpretation of [graph.size] as pixels -- scale down for text
lukstafi Sep 26, 2024
55a87a4
Consistently prefer plots coming first; docu-comments; prevent out-of…
lukstafi Sep 26, 2024
fecfa6e
Fix determining the y range from `Line_plot_adaptive`
lukstafi Sep 26, 2024
53b4dcc
A couple more plotting primitives
lukstafi Sep 26, 2024
1db9608
Plotting with nested boxes
lukstafi Sep 26, 2024
4f70815
Fix nested plotting: overlapping boxes were badly mishandled
lukstafi Sep 26, 2024
1422acf
Plotting test: Fix lower bounds error (OCaml < 4.13)
lukstafi Sep 26, 2024
3c48283
Plotting: arbitrary box overlaps with priorities like layers in graph…
lukstafi Sep 26, 2024
4ef13cc
Plotting: Fix lower bounds error (OCaml < 4.10), but also shorter
lukstafi Sep 26, 2024
0070030
Plotting PR: revert the introduction of `PrintBox.is_empty`
lukstafi Sep 27, 2024
6db15d2
Plotting PR: 2 tiny typos
lukstafi Sep 27, 2024
dc95393
Plotting PR: cleaner and faster `get_extension_handler`
lukstafi Sep 27, 2024
8a4ae1f
Plotting with html backend: fix z-index ordering, make framed=opaque
lukstafi Sep 27, 2024
2333c86
Greatly simplify the extensibility desing; pass config to handlers
lukstafi Sep 28, 2024
c1bdc61
Standalone test for extending `printbox-md` since its dependencies ca…
lukstafi Sep 30, 2024
1692771
Standalone test for extending `printbox-html`, its dependency on `pri…
lukstafi Sep 30, 2024
196ecb1
More docu-comments for the plotting extension
lukstafi Sep 30, 2024
758efdd
`PrintBox_ext_plot.graph`: Rename `no_axes` -> `axes`
lukstafi Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ including:

See https://c-cube.github.io/printbox/

See the [test/](test/) and [examples/](examples/) directories for illustrations of potential usage.

## License

BSD-2-clauses
Expand Down
14 changes: 14 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ Printbox allows to print nested boxes, lists, arrays, tables in several formats"
(printbox-html (and (= :version)))
(odoc :with-test)
(mdx (and (>= 1.4) :with-test))))

(package
(name printbox-ext-plot)
(synopsis "Printbox extension for plotting")
(description "
Extends Printbox with the ability to print scatter plots, line plots, decision boundaries.
Printbox allows to print nested boxes, lists, arrays, tables in several formats")
(depends (printbox (= :version))
(printbox-text (and (= :version)))
(printbox-html (and (= :version)))
(printbox-md (and (= :version)))
(tyxml (>= 4.3))
(odoc :with-test)
(mdx (and (>= 1.4) :with-test))))
39 changes: 39 additions & 0 deletions printbox-ext-plot.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.11"
synopsis: "Printbox extension for plotting"
description: """

Extends Printbox with the ability to print scatter plots, line plots, decision boundaries.
Printbox allows to print nested boxes, lists, arrays, tables in several formats"""
maintainer: ["c-cube" "lukstafi"]
authors: ["Simon Cruanes" "Guillaume Bury" "lukstafi"]
license: "BSD-2-Clause"
homepage: "https://github.com/c-cube/printbox"
bug-reports: "https://github.com/c-cube/printbox/issues"
depends: [
"dune" {>= "3.0"}
"printbox" {= version}
"printbox-text" {= version}
"printbox-html" {= version}
"printbox-md" {= version}
"tyxml" {>= "4.3"}
"odoc" {with-test}
"mdx" {>= "1.4" & with-test}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/c-cube/printbox.git"
8 changes: 8 additions & 0 deletions src/PrintBox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module Style = struct
let fg_color c : t = set_fg_color c default
end

type ext = ..

type view =
| Empty
| Text of {
Expand All @@ -64,6 +66,10 @@ type view =
id: string;
inner: t;
}
| Ext of {
key: string;
ext: ext;
}

and t = view

Expand Down Expand Up @@ -203,6 +209,7 @@ let mk_tree ?indent f root =

let link ~uri inner : t = Link { uri; inner }
let anchor ~id inner : t = Anchor { id; inner }
let extension ~key ext = Ext { key; ext }

(** {2 Simple Structural Interface} *)

Expand All @@ -219,6 +226,7 @@ module Simple = struct
| `Table of t array array
| `Tree of t * t list
]
(** The simple interface does not support extensions. *)

let rec to_box = function
| `Empty -> empty
Expand Down
16 changes: 16 additions & 0 deletions src/PrintBox.mli
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ type t
(** Main type for a document composed of nested boxes.
@since 0.2 the type [t] is opaque *)

type ext = ..
(** Extensions of the representation.

@since NEXT_RELEASE
*)

(** The type [view] can be used to observe the inside of the box,
now that [t] is opaque.

Expand Down Expand Up @@ -137,6 +143,10 @@ type view = private
id: string;
inner: t;
}
| Ext of {
key: string;
ext: ext;
}

val view : t -> view
(** Observe the content of the box.
Expand Down Expand Up @@ -317,6 +327,12 @@ val anchor : id:string -> t -> t
@since 0.11
*)

val extension : key:string -> ext -> t
(** [extension ~key ext] embeds an extended representation [ext] as a box. [ext] must be
recognized by the used backends as an extension registered under [key].
@since NEXT_RELEASE
*)

(** {2 Styling combinators} *)

val line_with_style : Style.t -> string -> t
Expand Down
Loading
Loading