[TxMt] R bundle: Command Usage
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Fri Dec 15 14:18:45 UTC 2006
Hi,
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:
1)
I don't use Ruby, only Bash with a tiny Perl snippet. It is a bit
faster.
2)
I'm looking for HTML files, not for tex files.
3)
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.
4)
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?
Best,
-Hans
More information about the textmate
mailing list