A python script that generate method stubs from selected method declarations and put in clipboard on Mac. It is a more general variation of generateStubsInClipboardFromSelection.py in xcodeScripts.
You can install by creating Service manually from the script or directly use pre-created Service.
- Open Automator application.
- Create a new Automator document with "Service" type.
- Change "Service receives" to "no input."
- Add a "Run Shell Script" action into the workflow at right.
- Change the "Shell" to "/usr/bin/python", and paste generateMethodStubsFromSelection.py content into the script text area.
- Save and give the service name "Generate Method Stubs."
- Open "System Preferences" and go to "Keyboard" -> "Shortcuts" -> "Services." Make sure "Generate Method Stubs" is checked and assign a keyboard shortcut to it (eg. ⇧⌥⌘ + C.)
- Move "Generate Method or Function Stubs.workflow" into "/Users/<#YOUR_HOME#>/Library/Services/."
- Do step 7. in "Install by Manually Create Service from generateMethodStubsFromSelection.py."
- Select some method declarations (include the semicolon ";") text in any application that support "Copy".
- Trigger the service you have installed by the keyboard shortcut (eg. ⇧⌥⌘ + C.)
For example: In Xcode, you select following code.
- (void)doSomething;
+ (id)objectWithSomething:(id)inSomething;
Press ⇧⌥⌘ + C. It will put following code in clipboard.
- (void)doSomething
{
}
+ (id)objectWithSomething:(id)inSomething
{
}
Then you can paste the method stubs at anywhere you want.
The python code get the method declarations strings by trigger the "Copy" menu item. After get the method declarations in clipboard, it replace all ";" to "{}" and put into clipboard.