Checks whether a given function returns a valid ggplot2 theme object when called with no arguments.
The function is executed in a separate R process to reduce risk, but is still ultimately unsafe.
Arguments
- f
A function expected to return a
ggplot2::themeobject. It must take no arguments.
Details
This function is useful for validating dynamically generated theme functions,
such as those produced by make_ai_theme(). The function f is called inside a
subprocess using callr::r() to limit the risk of evaluating untrusted or erroneous code.
However, it's important to note that not all risk is mitigated.
The result must inherit from both "theme" and "gg", as expected from objects
returned by standard ggplot2 theme functions like ggplot2::theme_minimal().
Note that the theme function must not require any arguments (e.g., base_size)
in order to be validated correctly.
Examples
check_theme(ggplot2::theme_minimal)