Closed moodymudskipper closed 3 years ago
{styler} also does syntax highlighting, which we could translate into the appropriate equivalent in the diagram language to get more beautiful code.
styler is used with default arguments, it's a quick fix. The styling needs to be done right when filling the data for the nomnoml engine, and we a way to set the style.
I think an argument style
defaulting to getOption("flow.style")
, itself by default set to the default styler style, would be good.
let's close for now, styler is good enough with defaults and at this point custom styles will probably just confuse the user and i don't want to commit to an interface without having good use cases.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
linked to https://github.com/moodymudskipper/flow/issues/37
There is no easy way to print the code as written. This is because the srcref stores lines, not calls, and delimiting calls is not obvious :
foo;bar # 2 calls on one line "foo;bar" if (TRUE) this else that
etc...
Basically we'd need to partially reimplement the parser in R language. And it's a non trivial task for little benefit.
So we use
base::deparse()
, but it's not really good enough.{{foo}}
should not print with new lines for instance.In case we try to decipher somebody else's code, one of the reason might be that we don't like the style they use, so even if we could see the code as written it might not be good enough.
A quick win would be to use the {styler} package.
The most flexible option would be to have a styler_transformer argument set either to
getOption("flow.transformer")
, by default it would beNULL
, or to the default styler transformer. In the former case styler can be add only to Suggests.Then we'd do
options(flow.transformer = my_transformer)
in our Rprofile or intitialization script.We could also have it only as options, to spare an argument.