-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a custom "Output_sink" module for emitting strings
OCaml doesn't have a good abstraction over writing text to generic output (file, stdout, to memory). As a result, we often end up using Format.formatter as an arbitrary output source. This is fine in some use-cases. However, Format is designed around pretty-printing values, rather than being high-performance. We see this particularly when emitting HTML, with the format machinery contributing a significant amount of time. This change adds a new Output_sink module, which effectively exposes a single "write" method. We switch the HTML module over to this. This provides a significant performance boost. For a CC:T doc-gen this reduces allocations and time taken by ~15%.
- Loading branch information
Showing
28 changed files
with
311 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(** Highlight a Lua string, rendering it as HTML *) | ||
val lua : options:Html_options.t -> string -> Html.Default.node | ||
val lua : options:Html_options.t -> string -> Illuaminate.Html.node_ | ||
|
||
val lua_block : | ||
?attrs:(string * string option) list -> options:Html_options.t -> string -> Html.Default.node | ||
?attrs:(string * string option) list -> options:Html_options.t -> string -> Illuaminate.Html.node_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
(** Load a file, converting it to a HTML node depending on the file's type. *) | ||
val load_file : options:Html_options.t -> Fpath.t -> (Html.Default.node, string) result | ||
val load_file : options:Html_options.t -> Fpath.t -> (Illuaminate.Html.node_, string) result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
open Html.Default; | ||
open Illuaminate.Html; | ||
open Html_basic; | ||
open Html_md; | ||
open Html_value; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
open Html.Default; | ||
open IlluaminateSemantics; | ||
|
||
/** Show an optional specifier if required. */ | ||
let show_opt: (~kind: string, bool) => node; | ||
let show_opt: (~kind: string, bool) => Illuaminate.Html.node_; | ||
|
||
/** Check if a type is optional (i.e. is a union contianing `nil`), and extract the non-optional type component if so. */ | ||
let opt_ty: Doc.Syntax.Type.t => (bool, Doc.Syntax.Type.t); | ||
|
||
/** Convert a type to HTML, using some resolve function to look up internal links. */ | ||
let show_type: (~options: Html_options.t, Doc.Syntax.Type.t) => node; | ||
let show_type: | ||
(~options: Html_options.t, Doc.Syntax.Type.t) => Illuaminate.Html.node_; | ||
|
||
/** Convert a potential type to HTML. */ | ||
let show_type_opt: | ||
(~options: Html_options.t, option(Doc.Syntax.Type.t)) => node; | ||
(~options: Html_options.t, option(Doc.Syntax.Type.t)) => | ||
Illuaminate.Html.node_; | ||
|
||
/** Wrap a HTML node with a link to a reference, using some resolve function to look up internal links. */ | ||
let show_reference: | ||
(~options: Html_options.t, Reference.resolved, node) => node; | ||
(~options: Html_options.t, Reference.resolved, Illuaminate.Html.node_) => | ||
Illuaminate.Html.node_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
open Html.Default; | ||
open Illuaminate.Html; | ||
open Html_basic; | ||
open Html_md; | ||
open Html_type; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.