The current Documentation for Word / Selection and Documentation for Selector in the Objective-C bundle doesn't find a many of the classes and selectors for lots of things now in Leopard (CAAnimation, for example) or in the iPhone SDK.
Having looked at the existing implementations of these commands I decided it would be easier to replace them rather than hack what was there already. My implementation of these commands uses an Apple supplied tool (docsetutil) to search for the word, etc. in the docsets so don't need any private index lists to find words quickly. This has the big advantage that the index is always up to date and covers every framework. The code is a lot simpler as well.
The only downside I can see is this may only work with Leopard - I don't know and don't have any easy way of finding if it works with Tiger. I didn't work through all the ramifications of the original selector identification code so it is possible my version has some holes - I have tried it with lots of examples and it seems to work, but if any problem cases are discovered I will be pleased to fix them.
To install this version copy the enclosed ruby file to /Applications/ TextMate.app/Contents/SharedSupport/Support/lib/ directory and edit the two commands (or make two new commands) as follows:
Documentation for Word:
#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + '/lib/docset_query' documentation_for_word
with input, output and scope selector as per the original. Will show a list of candidates if more than one and also prefix them with the language if more than one is present (hint try selecting init outside of a [ ].
Documentation for Selector:
#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + '/lib/docset_query' documentation_for_selector
with input set to "Entire Document", output "Show as Tool Tip" and scope selector as per the original.
If there is interest in absorbing this work into the official distribution that is fine by me and I hope I haven't committed any sins in where the helper file is stored.
Dave.
On 16 Apr 2008, at 14:16, Dave Baldwin wrote:
The current Documentation for Word / Selection and Documentation for Selector in the Objective-C bundle doesn't find a many of the classes and selectors for lots of things now in Leopard (CAAnimation, for example) or in the iPhone SDK.
Having looked at the existing implementations of these commands I decided it would be easier to replace them rather than hack what was there already. My implementation of these commands uses an Apple supplied tool (docsetutil) to search for the word, etc. in the docsets so don't need any private index lists to find words quickly. [...]
This is awesome, thanks!
Definitely we will role this into the default bundle. We can do a check for 10.4 and fall back on the old stuff in that case, as this is too good a gem to pass on :)
Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
On 26 May 2008, at 22:17, Allan Odgaard wrote:
On 16 Apr 2008, at 14:16, Dave Baldwin wrote:
The current Documentation for Word / Selection and Documentation for Selector in the Objective-C bundle doesn't find a many of the classes and selectors for lots of things now in Leopard (CAAnimation, for example) or in the iPhone SDK.
Having looked at the existing implementations of these commands I decided it would be easier to replace them rather than hack what was there already. My implementation of these commands uses an Apple supplied tool (docsetutil) to search for the word, etc. in the docsets so don't need any private index lists to find words quickly. [...]
This is awesome, thanks!
Definitely we will role this into the default bundle. We can do a check for 10.4 and fall back on the old stuff in that case, as this is too good a gem to pass on :)
Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
Version with the man stuff and some other fixes.
Dave.
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
On 27 May 2008, at 09:44, Dave Baldwin wrote:
[...] Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
Version with the man stuff and some other fixes.
I get a redirect to file://localhost(null) for e.g. fprintf (and also unknown stuff).
The Documentation For Selector is now throwing an error.
On 27 May 2008, at 08:52, Allan Odgaard wrote:
On 27 May 2008, at 09:44, Dave Baldwin wrote:
[...] Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
Version with the man stuff and some other fixes.
I get a redirect to file://localhost(null) for e.g. fprintf (and also unknown stuff).
The Documentation For Selector is now throwing an error.
This is most strange - both things work fine for me. Can you be more specific on what is happening?
Dave.
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
On 27 May 2008, at 10:12, Dave Baldwin wrote:
On 27 May 2008, at 08:52, Allan Odgaard wrote:
On 27 May 2008, at 09:44, Dave Baldwin wrote:
[...] Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
Version with the man stuff and some other fixes.
I get a redirect to file://localhost(null) for e.g. fprintf (and also unknown stuff).
The Documentation For Selector is now throwing an error.
This is most strange - both things work fine for me. Can you be more specific on what is happening?
This is how I patched the Objective-C bundle to use your script: http://pastie.textmate.org/203978 (and I copied your ruby lib into Support/lib in that bundle).
If I create a new document, set language to Objective-C and enter just ‘fprintf()’ and press ⌃H on that word, I get a “not found” error message (in the HTML output window).
If I enter ‘[dict objectForKey:key]’ and press ⌃H when inside the brackets, I get:
docset_query.rb:108:in `documentation_for_selector': undefined method `length' for nil:NilClass (NoMethodError) from /tmp/temp_textmate.M5yawa:4:in `inject' from docset_query.rb:108:in `each' from docset_query.rb:108:in `inject' from docset_query.rb:108:in `documentation_for_selector' from /tmp/temp_textmate.M5yawa:5
On 27 May 2008, at 14:32, Allan Odgaard wrote:
On 27 May 2008, at 10:12, Dave Baldwin wrote:
On 27 May 2008, at 08:52, Allan Odgaard wrote:
On 27 May 2008, at 09:44, Dave Baldwin wrote:
[...] Also, I need it to fallback on ‘man’ (section 2-9) so it still finds documentation for stuff in the standard C library and POSIX. I’ll look into that in the nearest future and then do a commit.
Version with the man stuff and some other fixes.
I get a redirect to file://localhost(null) for e.g. fprintf (and also unknown stuff).
The Documentation For Selector is now throwing an error.
This is most strange - both things work fine for me. Can you be more specific on what is happening?
This is how I patched the Objective-C bundle to use your script: http://pastie.textmate.org/203978 (and I copied your ruby lib into Support/lib in that bundle).
If I create a new document, set language to Objective-C and enter just ‘fprintf()’ and press ⌃H on that word, I get a “not found” error message (in the HTML output window).
Do you mean an empty HTML window with a 'Table of Contents' hyperlink that goes nowhere? - I get this if I put in fprintfff which I know doesn't exist. fprintf on the other hand gives the expected result for me.
Do have a method called man_page (query) in your version of docdet_query.rb?
If I enter ‘[dict objectForKey:key]’ and press ⌃H when inside the brackets, I get:
docset_query.rb:108:in `documentation_for_selector': undefined method `length' for nil:NilClass (NoMethodError) from /tmp/temp_textmate.M5yawa:4:in `inject' from docset_query.rb:108:in `each' from docset_query.rb:108:in `inject' from docset_query.rb:108:in `documentation_for_selector' from /tmp/temp_textmate.M5yawa:5
This is expecting the entire document as input whereas the original version is expecting the selected text or scope as input (I think). Maybe this is causing the problem?
Dave.
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
On 27 May 2008, at 16:26, Dave Baldwin wrote:
[...] If I create a new document, set language to Objective-C and enter just ‘fprintf()’ and press ⌃H on that word, I get a “not found” error message (in the HTML output window).
Do you mean an empty HTML window with a 'Table of Contents' hyperlink that goes nowhere? - I get this if I put in fprintfff which I know doesn't exist. fprintf on the other hand gives the expected result for me.
Do have a method called man_page (query) in your version of docdet_query.rb?
I do, but I have a space in TM_SUPPORT_PATH, which was the problem.
[...] This is expecting the entire document as input whereas the original version is expecting the selected text or scope as input (I think). Maybe this is causing the problem?
Yes, I had not changed input of the command.
I made a few changes to docset_query.rb: http://pastie.textmate.org/205314
Presently there is the problem that Apple’s docs will eclipse the POSIX / C lib stuff. For example ⌃H on open, read, exit, etc. will give Apple documentation. So it might be necessary to both query docset and man, rather than have man as a fallback.
When querying man, probably section 1 (shell commands) should be left out. For example ⌃H on ‘ulimit’ will show the (less useful from C) <x-man-page://1/ ulimit> instead of x-man-page://3/ulimit.
On 29 May 2008, at 12:21, Allan Odgaard wrote:
Allan, am glad these problems have been resolved - makes me appreciate what you have to do daily in supporting TextMate!
This version has the following changes: 1. Incorporated your changes. 2. Search is done across all docsets and man pages and the results integrated for user selection if more than one. This fixes functions such as open that occur in the man pages as well as in docsets. It also fixes the case when method names appear in more than one docset. 3. Only man sections 2 and 3 are searched.
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
On Wed, Apr 16, 2008 at 5:16 AM, Dave Baldwin dave.baldwin@3dlabs.com wrote:
The current Documentation for Word / Selection and Documentation for Selector in the Objective-C bundle doesn't find a many of the classes and selectors for lots of things now in Leopard (CAAnimation, for example) or in the iPhone SDK.
Having looked at the existing implementations of these commands I decided it would be easier to replace them rather than hack what was there already. My implementation of these commands uses an Apple supplied tool (docsetutil) to search for the word, etc. in the docsets so don't need any private index lists to find words quickly. [...]
Dave,
Wanted to say thank you for writing and sharing your script. It's really handy to look up iPhone APIs without leaving TM.
-peter