-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_title_case
executable file
·30 lines (26 loc) · 1.04 KB
/
get_title_case
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -e
R_FILES="R/core.R R/shapes.R R/text.R R/models.R R/textures.R R/rcamera.R"
function gen_title_case()
{
cat "$1" |\
sed -n -E 's/^[[:space:]]*(.+)[[:space:]]*<-[[:space:]]*function.*$/\1/p' |\
sed -n -E "s/.*/#' @rdname \0\n#' @export\n\0<- \0\n/pg" |\
Rscript -e '
conn <- file("stdin")
input <- readLines(conn)
lines <- which(grepl(r"{^.+[[:space:]]*<-[[:space:]]*.+$}", input))
input[lines] <- gsub(r"{_(.)(?=.*<-)|^(.)(?=.*<-)}", r"{\U\1\U\2}", input[lines], perl = TRUE)
writeLines(input)
'
}
function gen_title_case_file()
{
echo "###########################################################"
echo "#The following file is auto generated, do not edit by hand#"
echo "###########################################################"
for f in $1; do
gen_title_case "$f"
done
}
gen_title_case_file "$R_FILES" > R/titlecase_autogen.R