diff --git a/Commands/Lookup in Documentation (10.9).tmCommand b/Commands/Lookup in Documentation (10.9).tmCommand new file mode 100644 index 0000000..cc23893 --- /dev/null +++ b/Commands/Lookup in Documentation (10.9).tmCommand @@ -0,0 +1,34 @@ + + + + + beforeRunningCommand + nop + command + #!/bin/bash +echo "<meta content='0;URL=file://$("${TM_BUNDLE_SUPPORT}/bin/ri_lookup" "${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}")' http-equiv='Refresh'>" + + hideFromUser + + input + none + inputFormat + text + name + Documentation for Word / Selection + outputCaret + afterOutput + outputFormat + html + outputLocation + newWindow + scope + source.ruby & attr.os-version.10.9 + semanticClass + lookup.define.ruby + uuid + FE882491-07FA-4497-B675-97FCF2FC3BF5 + version + 2 + + diff --git a/Commands/Lookup in Documentation.plist b/Commands/Lookup in Documentation.plist index 7bc9a19..5b95a83 100644 --- a/Commands/Lookup in Documentation.plist +++ b/Commands/Lookup in Documentation.plist @@ -11,12 +11,12 @@ "${TM_BUNDLE_SUPPORT}/bin/linked_ri.rb" fallbackInput word + hideFromUser + input selection inputFormat text - keyEquivalent - ^h name Documentation for Word / Selection outputCaret @@ -26,7 +26,7 @@ outputLocation toolTip scope - source.ruby, source.ruby.rails + source.ruby semanticClass lookup.define.ruby uuid diff --git a/Proxies/Documentation for Word : Selection.tmProxy b/Proxies/Documentation for Word : Selection.tmProxy new file mode 100644 index 0000000..d98cad1 --- /dev/null +++ b/Proxies/Documentation for Word : Selection.tmProxy @@ -0,0 +1,16 @@ + + + + + content + lookup.define.ruby + keyEquivalent + ^h + name + Documentation for Word / Selection + scope + source.ruby + uuid + D5660BB2-C554-4694-9E0F-F20CDB6B9EA0 + + diff --git a/Support/bin/ri_lookup b/Support/bin/ri_lookup new file mode 100755 index 0000000..6948437 --- /dev/null +++ b/Support/bin/ri_lookup @@ -0,0 +1,9 @@ +#!/bin/bash + +PHRASE=$1 + +DST=$(mktemp "${TMPDIR:-/tmp}/tm_ruby_ri_XXXXXX").html +"$TM_BUNDLE_SUPPORT/bin/ri_to_html" &>"$DST" "$PHRASE" +echo -n "$DST" + +{ sleep 300; rm "$DST"; rm "${DST%.html}"; } &>/dev/null & diff --git a/Support/bin/ri_to_html b/Support/bin/ri_to_html new file mode 100755 index 0000000..4be5f01 --- /dev/null +++ b/Support/bin/ri_to_html @@ -0,0 +1,54 @@ +#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU +require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/htmloutput.rb" +require "shellwords" + +RI_EXE = '/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ri' + +def make_link(text, term) + "#{text}" +end + +phrase = *ARGV +page = %x{ #{RI_EXE} --no-pager -f markdown #{phrase.shellescape} 2>&1 } + +page.gsub!(/&/, '&') +page.gsub!(/ tag and it also ignores the com.apple.TextEncoding extended attribute. + +TextMate::HTMLOutput.show(:title => "Documentation for “#{phrase}”", :sub_title => `#{RI_EXE} --version`) do |io| + io << '' << "\n" + + in_pre, whitespace = false, "" + page.each_line do |line| + if line =~ /^(#+) (.+)/ + if in_pre + io << "" + in_pre = false + end + io << "#$2\n" + elsif line =~ /^---$/ + if in_pre + io << "" + in_pre = false + end + io << "
\n" + elsif line =~ /^\s*$/ + whitespace << line + else + if in_pre + io << whitespace + else + io << "
\n"
+        in_pre = true
+      end
+      io << line
+      whitespace = ""
+    end
+  end
+
+  io << "
" if in_pre +end diff --git a/info.plist b/info.plist index beaab5a..c1e7ff3 100644 --- a/info.plist +++ b/info.plist @@ -41,7 +41,7 @@ 35222962-C50D-4D58-A6AE-71E7AD980BE4 5289EE40-86B8-11D9-A8D4-000A95E13C98 ------------------------------------ - 63F3B3B7-CBE2-426B-B551-657733F3868B + D5660BB2-C554-4694-9E0F-F20CDB6B9EA0 6EA7AE06-3EA9-497D-A6DE-732DE43DA6E9 ------------------------------------ 8646378E-91F5-4771-AC7C-43FC49A93576 @@ -436,7 +436,7 @@ 35222962-C50D-4D58-A6AE-71E7AD980BE4 5289EE40-86B8-11D9-A8D4-000A95E13C98 - 63F3B3B7-CBE2-426B-B551-657733F3868B + D5660BB2-C554-4694-9E0F-F20CDB6B9EA0 1AD6A138-2E89-4D6A-AB3F-416BF9CE968D 931DD73E-615E-476E-9B0D-8341023AE730 DAA69A0C-FC1E-4509-9931-DFFB38B4D6AE