What is texscan? I never knew that, so I always just ignored the command ;)
I'm not sure the command is necessary, though, as you can get help on each function really easily, and if you need a template for args, there's always Insert Command Template.
Arguably, this shows the default S3 method args when you give it the root, like it shows the args for mean.default when you give it mean, but Insert Command Template could always be tweaked to use foo.default if you just give it foo (and foo.default exists).
Incidentally, COM=`cat` should work just as well as COM=`tail`. Any particular reason to use tail when you don't need the truncating abilities of that tool?
On Dec 15, 2006, at 9:18 AM, Hans-Joerg Bibiko wrote:
Regarding to the R-bundle command 'Command Usage':
I find this idea very good, but it supposes that on every Mac 'texscan' is installed.
So here's my suggestion for it:
I don't use Ruby, only Bash with a tiny Perl snippet. It is a bit faster.
I'm looking for HTML files, not for tex files.
It could happen that the structure of a help file is inconsistent, i.e. no 'Usage' header. If so, now it outputs the first 1100 character of the help as plain text. Maybe you find what do you are looking for.
I suppressed the error messages coming from the 'find' command mentioning that there is no permission to do something.
Here the code:
COM=`tail`
FILES=`find "${R_HOME:-/Library/Frameworks/R.framework/Resources}"/ library -name $COM.html -print 2>/dev/null`
if [ ${#FILES} -eq 0 ]; then echo "Nothing found for '$COM'" exit_show_tool_tip fi
for F in $FILES do cat "$F" | perl -e '$a="";while(<>){$a.=$_};$a=~m/<h3>Usage</h3> [.|\n]+<pre>(.*?)</pre>/sim;if($1){print "Usage:\n".$1;}else{$a=~s/ <.*?>//gms;$a=~s/\n{3,}/\n\n/gms;print substr($a,0,1100)."\n[...]"}' done __________________
Any comments?