Skip to content

Commit

Permalink
Adding formatting of R code to tools/format.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
llaniewski committed Dec 20, 2023
1 parent cd5be39 commit 4f505d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/conf.R
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@ AllKernels = expand.grid(
Globals=Enums$eCalculateGlobals[1:3],
Model=Enums$eModel,
Stage=Stages$name
# Stage=Enums$eStage
)

AllKernels$adjoint = (AllKernels$Op %in% c("Adjoint","Opt"))
Expand Down
23 changes: 16 additions & 7 deletions tools/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ function formatRT {
R -s -e 'rtemplate::RTtokenize()' | format | R -s -e 'rtemplate::RTtokenize(inv=TRUE)'
}

function formatR {
R -s -e "formatR::tidy_source('stdin', wrap=FALSE, args.newline=TRUE)"
}

function format_sel {
if [[ -z "$1" || "$1" =~ \.[rR][tT]$ ]]
then
echo formatRT
else
echo format
fi
case "$1" in
*.[rR][tT])
echo formatRT
;;
*.[rR])
echo formatR
;;
*)
echo format
;;
esac
}

function format_to {
Expand Down Expand Up @@ -106,7 +115,7 @@ do
exit 4
fi
PRINTSKIP=false
find "$FROM_DIR" | grep -E '[.](cpp|h|hpp)([.]Rt|)$' | while read i
find "$FROM_DIR" | grep -E '[.](cpp|h|hpp|cu|c|R)([.]Rt|)$' | while read i
do
if test "$FROM_DIR" == "$TO_DIR"
then
Expand Down

0 comments on commit 4f505d0

Please sign in to comment.