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
This is R html help files, not rdoc.
Unless your "rdoc" is different than the "rdoc" I know, which is the Ruby documentation utility.
On Dec 15, 2006, at 11:09 PM, hadley wickham wrote:
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'm pretty sure usage is required in rdoc files.
Sorry, I meant rd files. And usage is required. Hadley
On 12/24/06, Kevin Ballard kevin@sb.org wrote:
This is R html help files, not rdoc.
Unless your "rdoc" is different than the "rdoc" I know, which is the Ruby documentation utility.
On Dec 15, 2006, at 11:09 PM, hadley wickham wrote:
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'm pretty sure usage is required in rdoc files.
-- Kevin Ballard http://kevin.sb.org kevin@sb.org http://www.tildesoft.com
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
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?
Hi Kevin,
On 24 Dec 2006, at 23:20, Kevin Ballard wrote:
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).
Yes of course. 'Insert Command Template' goes hand in hand with 'Command Usage'.
My point was that 'Command Usage' could be sometimes helpful, if I only want to know, what is the default of a variable, for instance. I don't know who wrote this command and why did he/she use 'texscan' to parse the R help files written in TeX. I also don't know this function 'texscan' but I suppose that this function gives you the text specified within the LaTeX tag \begin {Usage}.
In order to use 'Command Usage' for everyone I rewrote it by searching within the HTML help files without any 'foreign' functions and I changed the behaviour of the system function 'find' to suppress the error messages.
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?
No, in that case you can easily write COM=`cat`.
__
My other question was who is 'responsible' for the R bundle and can upload this changed version? I know the bundles are more or less a collaborative work but I believe that someone should organize these ;)
Best,
Hans
On Jan 3, 2007, at 11:02 AM, Hans-Joerg Bibiko wrote:
Hi Kevin,
On 24 Dec 2006, at 23:20, Kevin Ballard wrote:
What is texscan? I never knew that, so I always just ignored the command ;)
Actually, it was tex.scan, which is a simple ruby command scanning the string given by the variable tex. I think Kevin by accident mistyped it. (You can see the revision diff).
What a difference a dot makes, eh?
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).
Yes of course. 'Insert Command Template' goes hand in hand with 'Command Usage'.
My point was that 'Command Usage' could be sometimes helpful, if I only want to know, what is the default of a variable, for instance. I don't know who wrote this command and why did he/she use 'texscan' to parse the R help files written in TeX. I also don't know this function 'texscan' but I suppose that this function gives you the text specified within the LaTeX tag \begin {Usage}.
I like the command too, though I don't really use it much at this point, (need to open the actual help file most of the times). I wrote the command originally, and looking at the revision history of the command would show that it was tex.scan. Does it work as expected if you make that change? If so, I don't really see the advantage of parsing the HTML file instead.
My other question was who is 'responsible' for the R bundle and can upload this changed version? I know the bundles are more or less a collaborative work but I believe that someone should organize these ;)
I think that's a bit unclear at the moment. Hadley Wickham, I think did the original import. Then Allan did some cleanup work on it. Then it stayed dormant for quite some time, until I started using R and started adding stuff to the bundle. Lately Kevin Ballard was using R and did some great work on the bundle. And now Hans has sent a lot of suggestions and improvements to the commands. So in some sense there is no official maintainer, though I would consider myself one of the maintainers, unfortunately overwhelmed at the moment with lots of other work, both textmate and real. If tex.scan instead of texscan works for you, then we can perhaps leave this command as is for now (well, with tex.scan instead of texscan).
Best,
Hans
Haris
On 03.01.2007, at 18:23, Charilaos Skiadas wrote:
On Jan 3, 2007, at 11:02 AM, Hans-Joerg Bibiko wrote:
Hi Kevin,
On 24 Dec 2006, at 23:20, Kevin Ballard wrote:
What is texscan? I never knew that, so I always just ignored the command ;)
Actually, it was tex.scan, which is a simple ruby command scanning the string given by the variable tex. I think Kevin by accident mistyped it. (You can see the revision diff).
What a difference a dot makes, eh?
OK. I changed it and now tex.scan works. (Actually I was a bit blind, the one thing I had to do is to read the ruby code ;) )
I like the command too, though I don't really use it much at this point, (need to open the actual help file most of the times). I wrote the command originally, and looking at the revision history of the command would show that it was tex.scan. Does it work as expected if you make that change? If so, I don't really see the advantage of parsing the HTML file instead.
Well, my HTML scan approach is to output everything which is written within the 'Usage' block.
Example:
##################### 'difftime'
tex.scan output: _________________ time1 - time2
html output: _________________ Usage:
time1 - time2
difftime(time1, time2, tz = "", units = c("auto", "secs", "mins", "hours", "days", "weeks"))
as.difftime(tim, format = "%X")
## S3 method for class 'difftime': round(x, digits = 0)
##################### 'matrix' tex.scan output: _________________ matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, (??)
html output: _________________ Usage:
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
as.matrix(x)
is.matrix(x)
Well, the question is what does the user expect by using 'Command Usage'
By my opinion the tex.scan version is very similar to the Kevin's 'Insert Command Template'. So I would suggest to use the HTML version instead. This is a bit more informative.
On the other hand if we decide to use the tex.scan version then it would be better to change the line
file = `find "${R_HOME:-/Library/Frameworks/R.framework/Resources}"/ library -name #{text}.tex -print`
into
file = `find "${R_HOME:-/Library/Frameworks/R.framework/Resources}"/ library -name #{text}.tex -print 2>/dev/null`
to speed up it a bit
and
we have to fix the 'bug' for matrix(), for instance, to display the whole definition.
Best, -Hans
On Jan 3, 2007, at 1:06 PM, Hans-Jörg Bibiko wrote:
On 03.01.2007, at 18:23, Charilaos Skiadas wrote:
On Jan 3, 2007, at 11:02 AM, Hans-Joerg Bibiko wrote:
OK. I changed it and now tex.scan works. (Actually I was a bit blind, the one thing I had to do is to read the ruby code ;) )
We all were ;)
I like the command too, though I don't really use it much at this point, (need to open the actual help file most of the times). I wrote the command originally, and looking at the revision history of the command would show that it was tex.scan. Does it work as expected if you make that change? If so, I don't really see the advantage of parsing the HTML file instead.
Well, my HTML scan approach is to output everything which is written within the 'Usage' block.
The command is now outputting everything in the Usage block that is in a verbatim environment, which I think should indeed be everything. This seems to take care of at least the two examples you mentioned, and makes its output similar to the HTML one.
However, this command should probably follow a similar process as the "Show in R Help" command to find what it should show. Right now it looks for a tex file named after the command, which I think it perhaps far from ideal. But that requires more work....
Best, -Hans
Haris
On 3 Jan 2007, at 23:17, Charilaos Skiadas wrote:
On Jan 3, 2007, at 1:06 PM, Hans-Jörg Bibiko wrote:
On 03.01.2007, at 18:23, Charilaos Skiadas wrote:
On Jan 3, 2007, at 11:02 AM, Hans-Joerg Bibiko wrote:
OK. I changed it and now tex.scan works. (Actually I was a bit blind, the one thing I had to do is to read the ruby code ;) )
We all were ;)
I like the command too, though I don't really use it much at this point, (need to open the actual help file most of the times). I wrote the command originally, and looking at the revision history of the command would show that it was tex.scan. Does it work as expected if you make that change? If so, I don't really see the advantage of parsing the HTML file instead.
Well, my HTML scan approach is to output everything which is written within the 'Usage' block.
The command is now outputting everything in the Usage block that is in a verbatim environment, which I think should indeed be everything. This seems to take care of at least the two examples you mentioned, and makes its output similar to the HTML one.
Now it works perfectly.
However, this command should probably follow a similar process as the "Show in R Help" command to find what it should show. Right now it looks for a tex file named after the command, which I think it perhaps far from ideal. But that requires more work....
I will look for a quick solution using the 'alias' tags within CONTENT files.
Hans
I think that's a bit unclear at the moment. Hadley Wickham, I think did the original import. Then Allan did some cleanup work on it. Then
Yes, I did the initial grammar, and a command to send selected text to the R application. I haven't contributed to anything else because that seems to be all I need for my way of working - (now) from the terminal, and using source frequently.
Hadley