Main /
JSFormattersSee AlsoAs part of software engineering in Ptolemy II, it would be good if we could clean the JS code. Unfortunately, it seems like the Eclipse JSDT is not available as part of Eclipse Cleanup for multiple files. Instead, I have to go to each file and clean it up individually. FeaturesRequired
Nice to have
js-beautifyTo install and run: npm install js-beautify svn co https://repo.eecs.berkeley.edu/svn/projects/terraswarm/accessors/trunk/accessors cd accessors ~/node_modules/js-beautify/js/bin/js-beautify.js --end-with-newline --replace --quiet --jslint-happy ./web/audio/AudioCapture.js svn diff web/audio/AudioCapture.js The options are
To run on all the files, first generate a list of files, see JSCleaning -> List of JS Files, then run $PTII/adm/bin/ptIItxtfiles >& /tmp/f cat /tmp/jss | xargs ~/node_modules/js-beautify/js/bin/js-beautify.js --end-with-newline --replace --quiet --jslint-happy EclipseEclipse has a http://eclipse.org/webtools/jsdt/ that can be installed in Eclipse:
Up Eclipse StyleIt is important to set up the JavaScript style to follow the Ptolemy II coding conventions.
Individual .js files can be viewed within the ptII Java project and formatted. CleanupIt is not clear how to clean up all the .js files automatically
EmacsEmacs includes a #! /bin/sh # -[Mon Feb 28 08:52:07 2005 by cxh]- # Indent Java code using emacs # Usage: jindent [-n] [-d] # -n Print what would happen, but don't checkout or modify files # # The Emacs CC-mode FAQ says: # *Q.* *How do I re-indent the whole file?* # # *A.* Visit the file and hit `C-x h' to mark the whole buffer. Then # hit `<ESC> C-\'. # # C-x h mark-whole-buffer # ESC C-\ indent-region #(fset 'jindent # "\C-xh\C-[\C-\\") printonly=no if [ "$1" = "-n" ]; then printonly=yes; shift fi emacs=emacs if [ "$PTII" = "" ]; then echo "$0: \$METRO is not set, exiting" exit 4 fi jindent_el=$PTII/util/lisp/jindent.el if [ ! -f "$jindent_el" ]; then echo "$0: '$jindent_el' not found, exiting" exit 5 fi BTW - ;; jindent.el, used by $PTII/util/testsuite/jindent to ;; indent Java files to the Ptolemy II standard ;; Version: $Id: jindent.el 22383 2002-05-04 20:57:09Z cxh $ (load (expand-file-name (concat (getenv "PTII") "/util/lisp/ptjavastyle.el"))) (defun jindent () (java-mode) (indent-region (point-min) (point-max) 'nil) (save-buffer) )
|