Title: | Debugging Tools to Inspect the Intermediate Steps of a Call |
---|---|
Description: | Provides debugging tools that let you inspect the intermediate results of a call. The output looks as if we explode a call into its parts hence the package name. |
Authors: | Antoine Fabri [aut, cre] |
Maintainer: | Antoine Fabri <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2024-11-17 06:32:47 UTC |
Source: | https://github.com/moodymudskipper/boomer |
Provides debugging tools that let you inspect the intermediate results of a call. The output looks as if we explode a call into its parts hence the package name.
boom()
displays the intermediate results of a call or a code chunk.
rig()
creates a copy of a function which will display the intermediate
results of all the calls of it body.
rig_in_namespace()
rigs a namespaced function in place, so its always
verbose even when called by other existing functions. It is especially handy
for package development.
rigger()
provides a convenient way to rig an
anonymous function by using the rigger(...) + function(...) {...}
syntax.
The addin "Explode a call with 'boom()'" provides a way to boom()
a call
with a keyboard shortcut.
Several options impact the display of exploded calls :
boomer.print
: If the print
argument is not provided, this option will
replace it at run time. Defaults to the base::print
function.
boomer.clock
: If the clock
argument is not provided, this option will
replace it at run time. Defaults to FALSE
.
boomer.print_args
: Whether to print the arguments of rigged functions
and their values when they are evaluated. Defaults to TRUE
.
boomer.visible_only
: Whether to hide the output of functions which return
invisibly. Defaults to FALSE
.
boomer.ignore
: Vector of function names or named list of functions for
which we don't want the result printed (usually because it's redundant). Defaults to
c("~", "{", "(", "<-", "<<-", "=")
.
boomer.ignore_args
: Vector of function names or named list of functions
for which we don't want the arguments boomed, this might be useful when calling a
function that loops too many times.
boomer.safe_print
: Whether to replace emoticons by characters compatible
with all systems. This is useful for reprexes (see reprex package) and
for knitted report in case the output of those doesn't look good on your system.
boomer.abbreviate
: Whether to show only the function's name rather than the
call when it's entered.
Maintainer: Antoine Fabri [email protected]
Useful links:
Report bugs at https://github.com/moodymudskipper/boomer/issues
boom()
prints the intermediate results of a call or a code chunk.
rig()
creates a copy of a function which will display the intermediate
results of all the calls of it body.
rig_in_namespace()
rigs a namespaced function in place, so its always
verbose even when called by other existing functions. It is especially handy
for package development.
rigger()
provides a convenient way to rig an
anonymous function by using the rigger(...) + function(...) {...}
syntax.
boom(expr, clock = NULL, print = NULL) rig(fun, clock = NULL, print = NULL) rigger(clock = NULL, print = NULL) rig_in_namespace(..., clock = NULL, print = NULL)
boom(expr, clock = NULL, print = NULL) rig(fun, clock = NULL, print = NULL) rigger(clock = NULL, print = NULL) rig_in_namespace(..., clock = NULL, print = NULL)
expr |
call to explode |
clock |
whether to time intermediate steps. Defaults to |
print |
A function, a formula or a list of functions or formulas, used to
modify the way the output is printed. Defaults to |
fun |
function ro |
... |
Functions to rig in their namespace If the rlang's formula notation is supported, so for instance you can type:
Sometimes you might want to print a specific type of object in a custom way,
in this case you can provide a named list, if you provide an unnamed element
it will be used as the default, and named elements will define how objects
of the given S3 class are printed. For instance |
boom()
returns the output of the call. rig()
returns the modified
input function. rig_in_namespace()
returns invisible(NULL)
and is called
for side effects. rigger()
returns a list containing the arguments, with
the class "rigger" to enable +.rigger
and print.rigger
# explode a simple call boom(subset(head(mtcars, 2), qsec > 17)) # clock calls and customize how to print output boom(subset(head(mtcars, 2), qsec > 17), clock = TRUE, print = str) # print str only for data frames boom(subset(head(mtcars, 2), qsec > 17), print = list(data.frame = str)) # rig an existing function rig(ave)(warpbreaks$breaks, warpbreaks$wool) # rig an anonymous function fun1 <- rigger() + function(x) x + 1 + 2 # same as rig(function(x) x + 1 + 2)) fun1(1) fun2 <- rigger(TRUE, typeof) + function(x) x + 1 + 2 fun2(1)
# explode a simple call boom(subset(head(mtcars, 2), qsec > 17)) # clock calls and customize how to print output boom(subset(head(mtcars, 2), qsec > 17), clock = TRUE, print = str) # print str only for data frames boom(subset(head(mtcars, 2), qsec > 17), print = list(data.frame = str)) # rig an existing function rig(ave)(warpbreaks$breaks, warpbreaks$wool) # rig an anonymous function fun1 <- rigger() + function(x) x + 1 + 2 # same as rig(function(x) x + 1 + 2)) fun1(1) fun2 <- rigger(TRUE, typeof) + function(x) x + 1 + 2 fun2(1)
While debugging a function, call boom_on()
and all subsequent calls will be boomed,
call boom_off()
to return to standard debugging.
boom_on(clock = NULL, print = NULL) boom_off()
boom_on(clock = NULL, print = NULL) boom_off()
clock |
whether to time intermediate steps. Defaults to |
print |
A function, a formula or a list of functions or formulas, used to
modify the way the output is printed. Defaults to |
Returns NULL
invisibly, called for side effects.
These works just like shiny::shinyApp
and shiny::runApp
and have the exact same parameters,
except they create/run a modified app that allows for easier debugging.
boom_shinyApp( ui, server, onStart = NULL, options = list(), uiPattern = "/", enableBookmarking = NULL ) boom_runApp( appDir = getwd(), port = getOption("shiny.port"), launch.browser = getOption("shiny.launch.browser", interactive()), host = getOption("shiny.host", "127.0.0.1"), workerId = "", quiet = FALSE, display.mode = c("auto", "normal", "showcase"), test.mode = getOption("shiny.testmode", FALSE) )
boom_shinyApp( ui, server, onStart = NULL, options = list(), uiPattern = "/", enableBookmarking = NULL ) boom_runApp( appDir = getwd(), port = getOption("shiny.port"), launch.browser = getOption("shiny.launch.browser", interactive()), host = getOption("shiny.host", "127.0.0.1"), workerId = "", quiet = FALSE, display.mode = c("auto", "normal", "showcase"), test.mode = getOption("shiny.testmode", FALSE) )
ui |
The UI definition of the app (for example, a call to
If bookmarking is enabled (see |
server |
A function with three parameters: |
onStart |
A function that will be called before the app is actually run.
This is only needed for |
options |
Named options that should be passed to the |
uiPattern |
A regular expression that will be applied to each |
enableBookmarking |
Can be one of |
appDir |
Path to directory that contains a Shiny app (i.e. a server.R file and either ui.R or www/index.html) |
port |
The TCP port that the application should listen on. If the
|
launch.browser |
If true, the system's default web browser will be launched automatically after the app is started. Defaults to true in interactive sessions only. The value of this parameter can also be a function to call with the application's URL. |
host |
The IPv4 address that the application should listen on. Defaults
to the |
workerId |
Can generally be ignored. Exists to help some editions of Shiny Server Pro route requests to the correct process. |
quiet |
Should Shiny status messages be shown? Defaults to FALSE. |
display.mode |
The mode in which to display the application. If set to
the value |
test.mode |
Should the application be launched in test mode? This is
only used for recording or running automated tests. Defaults to the
|
For this function to work properly the main server function should always be
assigned to an object (usually you'd name it server
).
For instance :
if you have a server.R
script, make sure to assign your function to server
if you use shinyServer
, create a server
function separately and use it
in your shinyServer
call.
It also assumes you follow standard practice in your use of callModule()
or
moduleServer()
.
See ?shiny::shinyApp
and ?shiny::runApp