From 148d3d366ff0e822dc7db5160c7a029060bd5b01 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 7 May 2020 16:53:46 -0700 Subject: [PATCH] [sledge] Cleanup ppx_trace docs Reviewed By: jvillard Differential Revision: D21441541 fbshipit-source-id: 939266e72 --- sledge/ppx_trace/ppx_trace.ml | 11 +++-------- sledge/ppx_trace/trace/trace.mli | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sledge/ppx_trace/ppx_trace.ml b/sledge/ppx_trace/ppx_trace.ml index 80e92ee6a..69ab47b80 100644 --- a/sledge/ppx_trace/ppx_trace.ml +++ b/sledge/ppx_trace/ppx_trace.ml @@ -11,18 +11,13 @@ "debug" mode or not. To enable "debug" mode, pass [--cookie 'ppx_trace_enabled="1"'] (or with [true] instead or [1]). - named "ppx_trace_enabled" declares a [--debug] command line option, to - be passed by the build system in debug but not optimized build modes. - Setting the [PPX_TRACE_ENABLED] environment variable to [1] or [true] - has the same effect as passing [--debug]. - It rewrites [\[%Trace.info f\]] to a call [\[Trace.info mod_name fun_name f\]] where [mod_name] and [fun_name] are the enclosing module and function names in the parsetree. This is only done in debug mode, otherwise [\[%Trace.info f\]] is rewritten to [()]. Similarly, [\[%Trace.call\]] is rewritten to a call to [Trace.call] or - [()], and [\[%Trace.retn\]] to a call to [Trace.retn] or [Fn.id]. + [()], and [\[%Trace.retn\]] to a call to [Trace.retn] or [Fun.id]. For example, this enables writing @@ -34,8 +29,8 @@ [%Trace.retn fun {pf} -> pf "%a" pp_result_type] ]} - to trace calls to [f] in debug mode while completely compiling out the - debug code in non-debug builds. + to trace calls to [func] in debug mode while completely compiling out + the debug code in non-debug builds. This mechanism can also be used e.g. to dynamically check assertions only in debug mode. diff --git a/sledge/ppx_trace/trace/trace.mli b/sledge/ppx_trace/trace/trace.mli index 462b216e3..2502212a4 100644 --- a/sledge/ppx_trace/trace/trace.mli +++ b/sledge/ppx_trace/trace/trace.mli @@ -22,7 +22,7 @@ type pf = {pf: 'a. 'a printf} val pp_styled : [`Bold | `Cyan | `Magenta] -> ('a, unit) fmt -> Format.formatter -> 'a -(** If config.colors is set to true, print in the specificed color *) +(** If config.colors is set to true, print in the specified color *) val printf : string -> string -> 'a printf (** Like [Format.printf], if enabled, otherwise like [Format.iprintf]. *)