-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement support for R including tests
- Loading branch information
Showing
4 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
" ============================================================================== | ||
" The R documentation should follow the 'Roxygen2' conventions. | ||
" see https://github.com/klutometis/roxygen | ||
" ============================================================================== | ||
|
||
let s:save_cpo = &cpoptions | ||
set cpoptions&vim | ||
|
||
let b:doge_patterns = [] | ||
|
||
" ============================================================================== | ||
" Matches regular functions. | ||
" ============================================================================== | ||
" | ||
" Matches the following scenarios: | ||
" | ||
" myFunc.default <- function( | ||
" p1, | ||
" p2.sub1 = FALSE, | ||
" p3.sub1 = 20, | ||
" p4.sub1 = 1/15, | ||
" ... | ||
" ) { | ||
" # ... | ||
" } | ||
|
||
" myFunc = function( | ||
" p1 = TRUE, p2_sub1= TRUE, p3 = FALSE, | ||
" p4 = 'libs', p5 = NULL, ..., p7 = 'default', | ||
" p8 = c('lorem', 'ipsum+dor', 'sit', 'amet'), | ||
" p9 = TRUE, p10 = list(), p11 = TRUE | ||
" ) { | ||
" # ... | ||
" } | ||
call add(b:doge_patterns, { | ||
\ 'match': '\m^\([[:alnum:]_.]\+\)\s*\%(=\|<-\)\s*function\s*(\(.\{-}\))\s*{', | ||
\ 'match_group_names': ['funcName', 'parameters'], | ||
\ 'parameters': { | ||
\ 'match': '\m\([[:alnum:]_]\+\%(.\%([[:alnum:]_]\+\)\)*\)\%(\s*=\s*\%([[:alnum:]_]\+(.\{-})\|[^,]\+\)\)\?', | ||
\ 'match_group_names': ['name'], | ||
\ 'format': ['@param', '{name}', 'TODO'], | ||
\ }, | ||
\ 'comment': { | ||
\ 'insert': 'above', | ||
\ 'template': [ | ||
\ "#' TODO", | ||
\ "#'", | ||
\ "#' {parameters}", | ||
\ "#'", | ||
\ "#' @export", | ||
\ "#'", | ||
\ ], | ||
\ }, | ||
\}) | ||
|
||
let &cpoptions = s:save_cpo | ||
unlet s:save_cpo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
# Functions | ||
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
#' TODO | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
myFunc = function() { | ||
# ... | ||
} | ||
|
||
#' TODO | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
myFunc <- function() { | ||
# ... | ||
} | ||
|
||
|
||
#' TODO | ||
#' | ||
#' @param p1 TODO | ||
#' @param p2.sub1 TODO | ||
#' @param p3.sub1 TODO | ||
#' @param p4.sub1 TODO | ||
#' | ||
#' @export | ||
#' | ||
myFunc.default <- function( | ||
p1, | ||
p2.sub1 = FALSE, | ||
p3.sub1 = 20, | ||
p4.sub1 = 1/15, | ||
... | ||
) { | ||
# ... | ||
} | ||
|
||
#' TODO | ||
#' | ||
#' @param p1 TODO | ||
#' @param p2_sub1 TODO | ||
#' @param p3 TODO | ||
#' @param p4 TODO | ||
#' @param p5 TODO | ||
#' @param p7 TODO | ||
#' @param p8 TODO | ||
#' @param p9 TODO | ||
#' @param p10 TODO | ||
#' @param p11 TODO | ||
#' | ||
#' @export | ||
#' | ||
myFunc = function( | ||
p1 = TRUE, p2_sub1= TRUE, p3 = FALSE, | ||
p4 = 'libs', p5 = NULL, ..., p7 = 'default', | ||
p8 = c('lorem', 'ipsum+dor', 'sit', 'amet'), | ||
p9 = TRUE, p10 = list(), p11 = TRUE | ||
) { | ||
# ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# ============================================================================== | ||
# Functions without parameters. | ||
# ============================================================================== | ||
Given r (functions without parameters): | ||
myFunc = function() { | ||
# ... | ||
} | ||
|
||
myFunc <- function() { | ||
# ... | ||
} | ||
|
||
Do (trigger doge): | ||
\<C-d> | ||
:10\<CR> | ||
\<C-d> | ||
|
||
Expect r (generated comments with nothing but the text 'TODO' and @export tag): | ||
#' TODO | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
myFunc = function() { | ||
# ... | ||
} | ||
|
||
#' TODO | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
myFunc <- function() { | ||
# ... | ||
} | ||
|
||
# ============================================================================== | ||
# Functions with parameters. | ||
# ============================================================================== | ||
Given r (function with parameters): | ||
myFunc = function( | ||
p1 = TRUE, p2_sub1= TRUE, p3 = FALSE, | ||
p4 = 'libs', p5 = NULL, ..., p7 = 'default', | ||
p8 = c('lorem', 'ipsum+dor', 'sit', 'amet'), | ||
p9 = TRUE, p10 = list(), p11 = TRUE | ||
) { | ||
# ... | ||
} | ||
|
||
Do (trigger doge): | ||
\<C-d> | ||
|
||
Expect r (generated comment with @param and @export tags): | ||
#' TODO | ||
#' | ||
#' @param p1 TODO | ||
#' @param p2_sub1 TODO | ||
#' @param p3 TODO | ||
#' @param p4 TODO | ||
#' @param p5 TODO | ||
#' @param p7 TODO | ||
#' @param p8 TODO | ||
#' @param p9 TODO | ||
#' @param p10 TODO | ||
#' @param p11 TODO | ||
#' | ||
#' @export | ||
#' | ||
myFunc = function( | ||
p1 = TRUE, p2_sub1= TRUE, p3 = FALSE, | ||
p4 = 'libs', p5 = NULL, ..., p7 = 'default', | ||
p8 = c('lorem', 'ipsum+dor', 'sit', 'amet'), | ||
p9 = TRUE, p10 = list(), p11 = TRUE | ||
) { | ||
# ... | ||
} |