Permalink
Browse files

Add support for classes in ⌃H "Documentation for Word" command

  • Loading branch information...
1 parent d170613 commit 667855a1d3246f8bccd37c68c550ba2efe7cb8e2 @joshvarner joshvarner committed with Josh Varner Dec 6, 2010
Showing with 63 additions and 58 deletions.
  1. +63 −58 Commands/Lookup word in PHP manual.plist
@@ -1,72 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundlePath</key>
<string>/Users/kumar/Library/Application Support/TextMate/Bundles/Custom.tmbundle</string>
<key>command</key>
- <string>if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'
- then
- if URL=`grep -i "^$TM_CURRENT_WORD=" "$TM_BUNDLE_SUPPORT/documentation.txt"`
- then
- URL=${URL:${#TM_CURRENT_WORD}+1}
- else
- URL="function.${TM_CURRENT_WORD//_/-}"
+ <string>if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'; then
+ if URL=`grep -i "^$TM_CURRENT_WORD=" "$TM_BUNDLE_SUPPORT/documentation.txt"`; then
+ URL=${URL:${#TM_CURRENT_WORD}+1}
+ else
+ URL="function.${TM_CURRENT_WORD//_/-}"
+ CLASS_URL="class.${TM_CURRENT_WORD//_/-}"
+ fi
+
+ if [[ "$PHP_MANUAL_LOCATION" ]]; then
+ if [[ ! -d "$PHP_MANUAL_LOCATION" ]]; then
+ exit_show_tool_tip "Your PHP_MANUAL_LOCATION directory ($PHP_MANUAL_LOCATION) does not exist. See the bundle Help for setup instructions."
+ fi
+
+ if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]]; then
+ URL=$CLASS_URL
fi
- if [[ "$PHP_MANUAL_LOCATION" ]]
- then
- if [[ ! -d "$PHP_MANUAL_LOCATION" ]]
- then
- exit_show_tool_tip "Your PHP_MANUAL_LOCATION directory ($PHP_MANUAL_LOCATION) does not exist. See the bundle Help for setup instructions."
- fi
- if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]]
- then
- exit_show_tool_tip "No documentation found for '$TM_CURRENT_WORD'"
- fi
- . "$TM_SUPPORT_PATH/lib/webpreview.sh"
- html_header "PHP Help" "${TM_FILENAME:-}"
- cat &lt;&lt;-'HTML'
- &lt;script type="text/javascript" charset="utf-8"&gt;
- function jump(page) {
- TextMate.isBusy = true;
- res = TextMate.system('cat "$PHP_MANUAL_LOCATION"/' + page, null).outputString;
- document.getElementById('php_help').innerHTML = res;
- TextMate.isBusy = false;
- setupLinks();
- historyList = document.getElementById('history_list');
- TextMate.log(historyList);
- item = document.createElement('option');
- TextMate.log(item);
- item.value = page;
- TextMate.log(page);
- item.innerText = res.match(/&gt;(.+?)&lt;\/TITLE/)[1];
- historyList.appendChild(item);
- item.selected = true;
- }
-
- function setupLinks() {
- var link, links = document.links;
- for (i = 0; i &lt; links.length; i++) {
- link = links[i];
- if (matches = link.href.match(/^file:.+\/(.+.html)$/)) {
- link.href = 'javascript:jump("' + matches[1] + '")';
- }
- }
- }
- &lt;/script&gt;
- HTML
- echo '&lt;select id="history_list" onchange="jump(this.options[this.selectedIndex].value)"&gt;&lt;/select&gt;'
- echo '&lt;div id="php_help"&gt;&lt;/div&gt;'
- echo '&lt;script&gt;jump("'"$URL"'.html");&lt;/script&gt;'
- html_footer
- exit_show_html
- else URL="http://php.net/manual/en/$URL.php"
+ if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]]; then
+ exit_show_tool_tip "No documentation found for '$TM_CURRENT_WORD'"
fi
- exit_show_html "&lt;meta http-equiv='Refresh' content='0;URL=$URL'&gt;"
- else echo "Nothing to lookup (hint: place the caret on a function name)"
+
+ . "$TM_SUPPORT_PATH/lib/webpreview.sh"
+ html_header "PHP Help" "${TM_FILENAME:-}"
+ cat &lt;&lt;-'HTML'
+ &lt;script type="text/javascript" charset="utf-8"&gt;
+ function jump(page) {
+ TextMate.isBusy = true;
+ res = TextMate.system('cat "$PHP_MANUAL_LOCATION"/' + page, null).outputString;
+ document.getElementById('php_help').innerHTML = res;
+ TextMate.isBusy = false;
+ setupLinks();
+
+ historyList = document.getElementById('history_list');
+ TextMate.log(historyList);
+ item = document.createElement('option');
+ TextMate.log(item);
+ item.value = page;
+ TextMate.log(page);
+ item.innerText = res.match(/&gt;(.+?)&lt;\/TITLE/)[1];
+ historyList.appendChild(item);
+ item.selected = true;
+ }
+
+ function setupLinks() {
+ var link, links = document.links;
+ for (i = 0; i &lt; links.length; i++) {
+ link = links[i];
+ if (matches = link.href.match(/^file:.+\/(.+.html)$/)) {
+ link.href = 'javascript:jump("' + matches[1] + '")';
+ }
+ }
+ }
+ &lt;/script&gt;
+ HTML
+ echo '&lt;select id="history_list" onchange="jump(this.options[this.selectedIndex].value)"&gt;&lt;/select&gt;'
+ echo '&lt;div id="php_help"&gt;&lt;/div&gt;'
+ echo '&lt;script&gt;jump("'"$URL"'.html");&lt;/script&gt;'
+ html_footer
+ exit_show_html
+ else
+ URL="http://php.net/manual/en/$URL.php"
+ fi
+ exit_show_html "&lt;meta http-equiv='Refresh' content='0;URL=$URL'&gt;"
+else
+ echo "Nothing to lookup (hint: place the caret on a function name)"
fi</string>
<key>input</key>
<string>none</string>

0 comments on commit 667855a

Please sign in to comment.