moodymudskipper / flow

View and Browse Code Using Flow Diagrams
https://moodymudskipper.github.io/flow/
Other
395 stars 26 forks source link

Use {styler} package ? #51

Closed moodymudskipper closed 3 years ago

moodymudskipper commented 3 years ago

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 be NULL, 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.

moodymudskipper commented 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.

moodymudskipper commented 3 years ago

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.

moodymudskipper commented 3 years ago

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.

github-actions[bot] commented 2 years ago

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.