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 :
if body is not {}, don't count as sub function
if body is not {} or has only one call in {}, don't count as sub function
one of the above, but excluding calls to control flow
a rule based on number of deparsed lines
a rule based on number of characters
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.
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 :
but maybe we can have
or
or
and named functions would have something like
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 :
{}
, don't count as sub function{}
or has only one call in{}
, don't count as sub functionWe 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.