moodymudskipper / flow

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

collapse sub functions #53

Open moodymudskipper opened 3 years ago

moodymudskipper commented 3 years ago

Since we can inspect the code of sub functions separately more conveniently, it would make sense to be able to get rid of the space that sub function definitions take.

This would especially be useful when generating full package doc, as the sub function diagrams would be one click away.

We have to decide what output we want, given that some functions are anonymous we cant have unambiguously just :

function(x, y) *...*

but maybe we can have

function(x, y) *.3.*

or

function(x, y) <..3..>

or

function(x, y) <body.3>

and named functions would have something like

foo <- function(x, y) <body.foo>

We don't want to collapse all anonymous functions though, that would be annoying not to see function(x) mean(x, na.rm = TRUE) for instance.

Possible rules might be :

We could have a boolean collapse_sub_funs which could also be a function taking the function and its name (if given), maybe also the main function name, as inputs and returning a boolean. some character or integer values could describe some presets.

A killer feature would be to have those highlighted in the code.

A related feature would be to put function definitions in italic dark grey by default, so they're still visible , but we can easily shut them off mentally.