Skip to content

Commit

Permalink
Added a command to wrap Docblock comments at 80 chars (disabled by de…
Browse files Browse the repository at this point in the history
…fault)

Updated the PHPDoc Help command
Added a Documentation for Tag command for PHPDoc info tags
Updated menu structure


git-svn-id: http://svn.textmate.org/trunk/Bundles/PHP.tmbundle@6651 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
ciaran committed Feb 26, 2007
1 parent c8f3871 commit 7607295
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 41 deletions.
25 changes: 25 additions & 0 deletions Commands/Documentation for Tag.tmCommand
@@ -0,0 +1,25 @@
<?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>if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '[@a-zA-Z]+'
then exit_show_html "&lt;meta http-equiv='Refresh' content='0;URL=http://manual.phpdoc.org/HTMLframesConverter/earthli/phpDocumentor/tutorial_tags.${TM_CURRENT_WORD#@}.pkg.html'&gt;"
else echo "Nothing to lookup (hint: place the caret on a tag)"
fi</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^h</string>
<key>name</key>
<string>Documentation for Tag</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>comment.block.documentation.phpdoc.php</string>
<key>uuid</key>
<string>42F50AE3-4F1C-43EB-9722-D80261A19625</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions Commands/PHPDoc Help.tmCommand
Expand Up @@ -25,6 +25,7 @@ This bundle contains snippets for use with [PHPDoc](http://phpdoc.org/).
* `doc_s ` — Abstract function signature * `doc_s ` — Abstract function signature
* `doc_v ` — Class variable * `doc_v ` — Class variable
* `doc_vp` — Class variable (post documentation) * `doc_vp` — Class variable (post documentation)
* `doc` — Generates a docblock for the item following the caret. Currently supports a class/interface, function, define or variable
_Commands marked as “post documentation” are designed for undocumented code — in other words, a comment block is added at the caret position._ _Commands marked as “post documentation” are designed for undocumented code — in other words, a comment block is added at the caret position._
Expand All @@ -35,6 +36,12 @@ The snippets make use of two environment variables (_set these under Preferences
* `TM_ORGANIZATION_NAME` — default value of @copyright [+ date] * `TM_ORGANIZATION_NAME` — default value of @copyright [+ date]
* `PHPDOC_AUTHOR` — default value of @author (realname will be used if not set) * `PHPDOC_AUTHOR` — default value of @author (realname will be used if not set)
If you want docblocks to automatically wrap after 80 columns, you need to set it up:
1. Open the Bundle Editor (&amp;#x2303;&amp;#x2325;&amp;#x2318;B)
2. Find and select the “Wrap Docblock at 80 Characters” command
3. Click in the white box next to “Key Equivalent” and press space
4. Close the Bundle Editor
EOF</string> EOF</string>
<key>input</key> <key>input</key>
<string>none</string> <string>none</string>
Expand Down
64 changes: 24 additions & 40 deletions Commands/Post-doc.tmCommand
Expand Up @@ -5,54 +5,38 @@
<key>beforeRunningCommand</key> <key>beforeRunningCommand</key>
<string>nop</string> <string>nop</string>
<key>command</key> <key>command</key>
<string>#!/usr/bin/ruby <string>. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header PHPDoc
next_line = STDIN.read.to_a[ENV['TM_LINE_NUMBER'].to_i..-1].join("\n").strip[/.+$/] Markdown.pl &lt;&lt;'EOF'
puts '/**' # Snippets
@tags = [] This bundle contains snippets for use with [PHPDoc](http://phpdoc.org/).
type = ''
author = true
def tag(tag, default, trailing = nil) * `doc_c ` — Class
@tags &lt;&lt; {:tag =&gt; tag, :default =&gt; default, :trailing =&gt; trailing} * `doc_cp` — Class (post documentation)
end * `doc_d ` — Define inline constant
* `doc_dp` — Define inline constant (post documentation)
* `doc_f ` — Function
* `doc_fp` — Function (post documentation)
* `doc_h ` — Document header
* `doc_i ` — Interface class
* `doc_s ` — Abstract function signature
* `doc_v ` — Class variable
* `doc_vp` — Class variable (post documentation)
* `doc` — Generates a docblock for the item following the caret (a class/interface, function, define or variable)
case next_line _Commands marked as “post documentation” are designed for undocumented code — in other words, a comment block is added at the caret position._
when /(class|interface)/
type = $&amp;
tag 'package', 'default'
when /function\s*\((.*)\)/
type = 'function'
$1.split(/,/).each do |arg|
tag 'param', 'string', '\\$' + arg[/[A-z0-9]+/].strip
end
tag 'return', 'void'
when /const|define/
type = 'constant'
author = false
when /var|p(ublic|rivate|rotected)/
type = 'variable'
tag 'var', 'string'
author = false
end
puts " * ${1:undocumented #{type}}" # Shell Variables
puts ' *' if @tags.size &gt; 0 or author
placeholder = 1 The snippets make use of two environment variables (_set these under Preferences &amp;#x2192; Advanced &amp;#x2192; Shell Variables_).
@tags.each do |tag|
placeholder += 1
if tag[:trailing]
puts " * @#{tag[:tag]} ${#{placeholder}:#{tag[:default]}} #{tag[:trailing] } \$#{placeholder += 1}"
else
puts " * @#{tag[:tag]} ${#{placeholder}:#{tag[:default]}}"
end
end
puts ' * @author ${PHPDOC_AUTHOR:`niutil -readprop / "/users/$USER" realname`}$' + (placeholder + 1).to_s if author * `TM_ORGANIZATION_NAME` — default value of @copyright [+ date]
puts ' */$0'</string> * `PHPDOC_AUTHOR` — default value of @author (realname will be used if not set)
EOF</string>
<key>fallbackInput</key> <key>fallbackInput</key>
<string>scope</string> <string>scope</string>
<key>input</key> <key>input</key>
Expand Down
27 changes: 27 additions & 0 deletions Commands/Wrap Docblock at 80 Characters.tmCommand
@@ -0,0 +1,27 @@
<?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/ruby
col = ENV['TM_COLUMN_NUMBER'].to_i
start_col = ENV['TM_CURRENT_LINE'].index('*')
if col - start_col &gt;= 80
puts
print " " * start_col + "*"
end
print " "</string>
<key>input</key>
<string>none</string>
<key>name</key>
<string>Wrap Docblock at 80 Characters</string>
<key>output</key>
<string>afterSelectedText</string>
<key>scope</key>
<string>comment.block.documentation.phpdoc.php</string>
<key>uuid</key>
<string>6F7E7868-F5A2-4B7D-ACFB-2A8DE2CD04E2</string>
</dict>
</plist>
23 changes: 22 additions & 1 deletion info.plist
Expand Up @@ -32,13 +32,26 @@
<string>34E2C808-8CCF-11D9-B507-000D93C8BE28</string> <string>34E2C808-8CCF-11D9-B507-000D93C8BE28</string>
<string>4833C612-8CCF-11D9-B507-000D93C8BE28</string> <string>4833C612-8CCF-11D9-B507-000D93C8BE28</string>
<string>------------------------------------</string> <string>------------------------------------</string>
<string>BB471E3A-8CCD-11D9-B507-000D93C8BE28</string>
<string>2B91DE5F-8CD0-11D9-B507-000D93C8BE28</string> <string>2B91DE5F-8CD0-11D9-B507-000D93C8BE28</string>
<string>CBF8F204-8CCF-11D9-B507-000D93C8BE28</string> <string>CBF8F204-8CCF-11D9-B507-000D93C8BE28</string>
<string>7720523B-8CCE-11D9-B507-000D93C8BE28</string> <string>7720523B-8CCE-11D9-B507-000D93C8BE28</string>
<string>93896C6F-4D1B-47EA-94B2-887CAB6ABFC2</string>
</array> </array>
<key>submenus</key> <key>submenus</key>
<dict> <dict>
<key>93896C6F-4D1B-47EA-94B2-887CAB6ABFC2</key>
<dict>
<key>items</key>
<array>
<string>BB471E3A-8CCD-11D9-B507-000D93C8BE28</string>
<string>117476CE-7A7F-4DC4-9A4E-772D282983A3</string>
<string>ED759470-69D7-4ADF-9842-D890DEB00F19</string>
<string>4F33617A-80FE-47D2-84AF-AA3D5D8A7128</string>
<string>1E34E416-CD16-4C16-A369-9CDC3FAFD4C4</string>
</array>
<key>name</key>
<string>HTML</string>
</dict>
<key>A3930E6A-FFFE-4E60-B797-052D34824F68</key> <key>A3930E6A-FFFE-4E60-B797-052D34824F68</key>
<dict> <dict>
<key>items</key> <key>items</key>
Expand Down Expand Up @@ -92,8 +105,10 @@
<key>items</key> <key>items</key>
<array> <array>
<string>EBD6D4CF-9F5E-4616-9880-5D3FF21EF408</string> <string>EBD6D4CF-9F5E-4616-9880-5D3FF21EF408</string>
<string>42F50AE3-4F1C-43EB-9722-D80261A19625</string>
<string>------------------------------------</string> <string>------------------------------------</string>
<string>775F7FCC-C43C-4C23-B935-9D5F6C25CF1D</string> <string>775F7FCC-C43C-4C23-B935-9D5F6C25CF1D</string>
<string>94D8B40B-9F49-4B6D-90B5-DBFF5FB36590</string>
<string>------------------------------------</string> <string>------------------------------------</string>
<string>9086BA3F-87E7-11D9-A6A3-000D93589AF6</string> <string>9086BA3F-87E7-11D9-A6A3-000D93589AF6</string>
<string>C65A0A03-956D-11D9-B0A1-000D93382786</string> <string>C65A0A03-956D-11D9-B0A1-000D93382786</string>
Expand Down Expand Up @@ -175,8 +190,14 @@
<string>9087051B-87E7-11D9-A6A3-000D93589AF6</string> <string>9087051B-87E7-11D9-A6A3-000D93589AF6</string>
<string>2CDD1B21-956E-11D9-B0A1-000D93382786</string> <string>2CDD1B21-956E-11D9-B0A1-000D93382786</string>
<string>908774B1-87E7-11D9-A6A3-000D93589AF6</string> <string>908774B1-87E7-11D9-A6A3-000D93589AF6</string>
<string>42F50AE3-4F1C-43EB-9722-D80261A19625</string>
<string>90872B90-87E7-11D9-A6A3-000D93589AF6</string> <string>90872B90-87E7-11D9-A6A3-000D93589AF6</string>
<string>90874D6F-87E7-11D9-A6A3-000D93589AF6</string> <string>90874D6F-87E7-11D9-A6A3-000D93589AF6</string>
<string>94D8B40B-9F49-4B6D-90B5-DBFF5FB36590</string>
<string>117476CE-7A7F-4DC4-9A4E-772D282983A3</string>
<string>ED759470-69D7-4ADF-9842-D890DEB00F19</string>
<string>4F33617A-80FE-47D2-84AF-AA3D5D8A7128</string>
<string>1E34E416-CD16-4C16-A369-9CDC3FAFD4C4</string>
</array> </array>
<key>uuid</key> <key>uuid</key>
<string>467A1966-6227-11D9-BFB1-000D93589AF6</string> <string>467A1966-6227-11D9-BFB1-000D93589AF6</string>
Expand Down

0 comments on commit 7607295

Please sign in to comment.