Skip to content

Commit

Permalink
Add new command Show RDoc for current file/project. This will generat…
Browse files Browse the repository at this point in the history
…e rdoc based on the current project (or file, if no project) and show it in the HTML window.

Also override the new toggle quote command for Ruby. It will now cycle between all 4 common quote styles; additionally, it will fiddle with escapes properly so, for example, switching to standard double-quote style will escape any double quotes already present.

git-svn-id: http://macromates.com/svn/Bundles/trunk/Bundles/Ruby.tmbundle@3015 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
kevin committed Apr 12, 2006
1 parent 6546bb8 commit 85fa9e4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Commands/Show RDoc for this file.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string>if (( ${#TM_PROJRECT_DIRECTORY} == 0 )); then
cd "$TM_PROJECT_DIRECTORY"
output="`basename "$TM_PROJECT_DIRECTORY"`"
input="."
else
cd "$TM_DIRECTORY"
output="$TM_FILENAME"
input="$TM_FILENAME"
fi
output_dir="/tmp/rdoc_${output}"
rm -rf "${output_dir}"
rdoc -S -N -q -f html --op "${output_dir}" "$input" &amp;&gt;/dev/null
echo "&lt;html&gt;&lt;head&gt;&lt;meta http-equiv=\"refresh\" content=\"0;URL=tm-file://${output_dir}/index.html\"&gt;&lt;/head&gt;&lt;/html&gt;"
</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^H</string>
<key>name</key>
<string>Show RDoc for current file/project</string>
<key>output</key>
<string>showAsHTML</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>1AD6A138-2E89-4D6A-AB3F-416BF9CE968D</string>
</dict>
</plist>
43 changes: 43 additions & 0 deletions Commands/Toggle Quote Style.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
class String
def escape(char)
gsub(/\\.|#{Regexp.quote(char)}/) { |match| match == char ? "\\#{char}" : match }
end
def unescape(char)
gsub(/\\./) { |match| match == "\\#{char}" ? char : match }
end
end
print case str = STDIN.read
when /\A"(.*)"\z/m: "%{" + $1.unescape('"').escape("}") + "}"
when /\A%\{(.*)\}\z/m: "'" + $1.unescape("}").escape("'") + "'"
when /\A'(.*)'\z/m: "%q{" + $1.unescape("'").escape("}") + "}"
when /\A%q\{(.*)\}\z/m: '"' + $1.unescape("}").escape('"') + '"'
else str
end
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^"</string>
<key>name</key>
<string>Toggle Quote Style</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
<string>source.ruby string.quoted.double, source.ruby string.quoted.single</string>
<key>uuid</key>
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
</dict>
</plist>
3 changes: 3 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<string>76FCF165-54CB-4213-BC55-BD60B9C6A3EC</string>
<string>63F3B3B7-CBE2-426B-B551-657733F3868B</string>
<string>EE5F1FB2-6C02-11D9-92BA-0011242E4184</string>
<string>1AD6A138-2E89-4D6A-AB3F-416BF9CE968D</string>
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
<string>EE5F1AE5-6C02-11D9-92BA-0011242E4184</string>
<string>0275EF39-9357-408F-AF20-79E415CA9504</string>
<string>7990EE60-C850-4779-A8C0-7FD2C853B99B</string>
Expand Down Expand Up @@ -49,6 +51,7 @@
<string>6FEAF60F-F0F3-4618-9259-DE93285F50D1</string>
<string>92E190C9-A861-4025-92D4-D6B5A24C22D4</string>
<string>6D75102B-6E51-4360-8F12-BE12327B6AE6</string>
<string>1D26F26C-C6F7-434F-84F8-FEE895372E8A</string>
</array>
<key>uuid</key>
<string>467B298F-6227-11D9-BFB1-000D93589AF6</string>
Expand Down

0 comments on commit 85fa9e4

Please sign in to comment.