Juri Pakaste avatar Juri Pakaste committed daae95c

Added an Automator workflow and documented it in the README. Added code block markup to the README.

Comments (0)

Files changed (3)

 Licensing
 ---------
 
-The NSStringFromEnumGenerator.py module and nsstringfromenumgen script are distributed under the terms of the MIT License. See LICENSE.TXT for details. The repository also includes and installs libclang Python bindings. See clang/LICENSE.TXT for details on them.
+The NSStringFromEnumGenerator.py module and nsstringfromenumgen script are distributed under the terms of the MIT License. See ``LICENSE.TXT`` for details. The repository also includes and installs libclang Python bindings. See ``clang/LICENSE.TXT`` for details on them.
 
 Requirements
 ------------
 Installation
 ------------
 
-To install, use ``setup.py``::
+To install, use ``setup.py``:
+
+.. code-block:: bash
 
  $ sudo python ./setup.py install
 
 Usage
 -----
 
-Call ``nsstringfromenumgen`` with one or more Objective-C source files. It parses them and outputs NSStringFromEnum functions for each enumeration found. It tries to be smart with typedefs and enum names and if it finds both names, it produces two functions. It also outputs an extern declaration for each function::
+Call ``nsstringfromenumgen`` with one or more Objective-C source files. It parses them and outputs NSStringFromEnum functions for each enumeration found. It tries to be smart with typedefs and enum names and if it finds both names, it produces two functions. It also outputs an extern declaration for each function:
+
+.. code-block:: bash
 
  $ nsstringfromenumgen Foo.h
+
+.. code-block:: objc
+
  extern NSString* NSStringFromAnEnum(AnEnum v);
  NSString* NSStringFromAnEnum(AnEnum v) {
    switch (v) {
    }
  }
 
-If your enums have values defined, they will be included too::
+If your enums have values defined, they will be included too:
+
+.. code-block:: objc
 
  extern NSString* NSStringFromValuesEnum(ValuesEnum v);
  NSString* NSStringFromValuesEnum(ValuesEnum v) {
 
 If your code relies on a prefix header, you need to include it on the command line with the ``--include`` flag. You can specify more than one of them if necessary.
 
-You can also instruct ``nsstringfromenumgen`` to treat your enums as options for a bitmask by including the ``--mask`` flag::
+You can also instruct ``nsstringfromenumgen`` to treat your enums as options for a bitmask by including the ``--mask`` flag:
+
+.. code-block:: bash
 
  $ nsstringfromenumgen Foo.h --mask
+
+.. code-block:: objc
+
  extern NSString* NSStringFromMaskEnum(enum MaskEnum v);
  NSString* NSStringFromMaskEnum(enum MaskEnum v) {
    NSMutableArray *bits = [NSMutableArray array];
    return [bits componentsJoinedByString:@" | "];
  }
 
+Service
+-------
+
+If you want to use ``nsstringfromenumgen`` as an OS X Service, there's an `Automator <http://support.apple.com/kb/HT2488>`_ workflow in ``service.workflow``. It's not installed by ``setup.py``, but you can use Automator to modify it as necessary and install it as a service. It assumes the following:
+
+1. You'll install the ``nsstringfromenumgen`` script in ``/usr/local/bin``,
+2. Have ``/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h`` which it includes automatically,
+3. You want to read stdin and copy the results to clipboard.
+
+If that sounds right and you install it as a service, you can feed it code blocks like:
+
+.. code-block:: objc
+
+   typedef NS_ENUM(NSInteger, AnEnum) {
+     AnEnumFirstValue,
+     AnEnumSecondValue
+   };
+
+and get the right thing on your clipboard.
+
 Caveats
 -------
 
Add a comment to this file

service.workflow/Contents/QuickLook/Thumbnail.png

Added
New image

service.workflow/Contents/document.wflow

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>AMApplicationBuild</key>
+	<string>346</string>
+	<key>AMApplicationVersion</key>
+	<string>2.3</string>
+	<key>AMDocumentVersion</key>
+	<string>2</string>
+	<key>actions</key>
+	<array>
+		<dict>
+			<key>action</key>
+			<dict>
+				<key>AMAccepts</key>
+				<dict>
+					<key>Container</key>
+					<string>List</string>
+					<key>Optional</key>
+					<true/>
+					<key>Types</key>
+					<array>
+						<string>com.apple.cocoa.string</string>
+					</array>
+				</dict>
+				<key>AMActionVersion</key>
+				<string>2.0.3</string>
+				<key>AMApplication</key>
+				<array>
+					<string>Automator</string>
+				</array>
+				<key>AMParameterProperties</key>
+				<dict>
+					<key>COMMAND_STRING</key>
+					<dict/>
+					<key>CheckedForUserDefaultShell</key>
+					<dict/>
+					<key>inputMethod</key>
+					<dict/>
+					<key>shell</key>
+					<dict/>
+					<key>source</key>
+					<dict/>
+				</dict>
+				<key>AMProvides</key>
+				<dict>
+					<key>Container</key>
+					<string>List</string>
+					<key>Types</key>
+					<array>
+						<string>com.apple.cocoa.string</string>
+					</array>
+				</dict>
+				<key>ActionBundlePath</key>
+				<string>/System/Library/Automator/Run Shell Script.action</string>
+				<key>ActionName</key>
+				<string>Run Shell Script</string>
+				<key>ActionParameters</key>
+				<dict>
+					<key>COMMAND_STRING</key>
+					<string>/usr/local/bin/nsstringfromenumgen --include /System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h -
+</string>
+					<key>CheckedForUserDefaultShell</key>
+					<true/>
+					<key>inputMethod</key>
+					<integer>0</integer>
+					<key>shell</key>
+					<string>/bin/sh</string>
+					<key>source</key>
+					<string></string>
+				</dict>
+				<key>BundleIdentifier</key>
+				<string>com.apple.RunShellScript</string>
+				<key>CFBundleVersion</key>
+				<string>2.0.3</string>
+				<key>CanShowSelectedItemsWhenRun</key>
+				<false/>
+				<key>CanShowWhenRun</key>
+				<true/>
+				<key>Category</key>
+				<array>
+					<string>AMCategoryUtilities</string>
+				</array>
+				<key>Class Name</key>
+				<string>RunShellScriptAction</string>
+				<key>InputUUID</key>
+				<string>E598252D-30E0-4D3B-85CC-7A6EF587B6F3</string>
+				<key>Keywords</key>
+				<array>
+					<string>Shell</string>
+					<string>Script</string>
+					<string>Command</string>
+					<string>Run</string>
+					<string>Unix</string>
+				</array>
+				<key>OutputUUID</key>
+				<string>5787DE17-8DE2-4250-8270-EE1474334181</string>
+				<key>UUID</key>
+				<string>EE488536-99AD-420A-9D27-0E52173C4CE8</string>
+				<key>UnlocalizedApplications</key>
+				<array>
+					<string>Automator</string>
+				</array>
+				<key>arguments</key>
+				<dict>
+					<key>0</key>
+					<dict>
+						<key>default value</key>
+						<integer>0</integer>
+						<key>name</key>
+						<string>inputMethod</string>
+						<key>required</key>
+						<string>0</string>
+						<key>type</key>
+						<string>0</string>
+						<key>uuid</key>
+						<string>0</string>
+					</dict>
+					<key>1</key>
+					<dict>
+						<key>default value</key>
+						<string></string>
+						<key>name</key>
+						<string>source</string>
+						<key>required</key>
+						<string>0</string>
+						<key>type</key>
+						<string>0</string>
+						<key>uuid</key>
+						<string>1</string>
+					</dict>
+					<key>2</key>
+					<dict>
+						<key>default value</key>
+						<false/>
+						<key>name</key>
+						<string>CheckedForUserDefaultShell</string>
+						<key>required</key>
+						<string>0</string>
+						<key>type</key>
+						<string>0</string>
+						<key>uuid</key>
+						<string>2</string>
+					</dict>
+					<key>3</key>
+					<dict>
+						<key>default value</key>
+						<string></string>
+						<key>name</key>
+						<string>COMMAND_STRING</string>
+						<key>required</key>
+						<string>0</string>
+						<key>type</key>
+						<string>0</string>
+						<key>uuid</key>
+						<string>3</string>
+					</dict>
+					<key>4</key>
+					<dict>
+						<key>default value</key>
+						<string>/bin/sh</string>
+						<key>name</key>
+						<string>shell</string>
+						<key>required</key>
+						<string>0</string>
+						<key>type</key>
+						<string>0</string>
+						<key>uuid</key>
+						<string>4</string>
+					</dict>
+				</dict>
+				<key>isViewVisible</key>
+				<true/>
+				<key>location</key>
+				<string>309.500000:619.000000</string>
+				<key>nibPath</key>
+				<string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string>
+			</dict>
+			<key>isViewVisible</key>
+			<true/>
+		</dict>
+		<dict>
+			<key>action</key>
+			<dict>
+				<key>AMAccepts</key>
+				<dict>
+					<key>Container</key>
+					<string>List</string>
+					<key>Optional</key>
+					<false/>
+					<key>Types</key>
+					<array>
+						<string>com.apple.cocoa.string</string>
+						<string>com.apple.cocoa.attributed-string</string>
+					</array>
+				</dict>
+				<key>AMActionVersion</key>
+				<string>1.2.1</string>
+				<key>AMApplication</key>
+				<array>
+					<string>System</string>
+				</array>
+				<key>AMParameterProperties</key>
+				<dict/>
+				<key>AMProvides</key>
+				<dict>
+					<key>Container</key>
+					<string>List</string>
+					<key>Optional</key>
+					<false/>
+					<key>Types</key>
+					<array>
+						<string>com.apple.cocoa.string</string>
+						<string>com.apple.cocoa.attributed-string</string>
+					</array>
+				</dict>
+				<key>ActionBundlePath</key>
+				<string>/System/Library/Automator/Copy to Clipboard.action</string>
+				<key>ActionName</key>
+				<string>Copy to Clipboard</string>
+				<key>ActionParameters</key>
+				<dict/>
+				<key>BundleIdentifier</key>
+				<string>com.apple.Automator.CopyToClipboard</string>
+				<key>CFBundleVersion</key>
+				<string>1.2.1</string>
+				<key>CanShowSelectedItemsWhenRun</key>
+				<true/>
+				<key>CanShowWhenRun</key>
+				<false/>
+				<key>Category</key>
+				<array>
+					<string>AMCategoryUtilities</string>
+				</array>
+				<key>Class Name</key>
+				<string>AMCopyToClipboardAction</string>
+				<key>InputUUID</key>
+				<string>74F97973-5205-4D21-ABCD-31DFC20019D5</string>
+				<key>Keywords</key>
+				<array>
+					<string>Copy</string>
+				</array>
+				<key>OutputUUID</key>
+				<string>D0E74AF5-930B-4F28-B270-C1603697F495</string>
+				<key>UUID</key>
+				<string>E04807B6-24EA-4133-B576-00796E8C6B39</string>
+				<key>UnlocalizedApplications</key>
+				<array>
+					<string>System</string>
+				</array>
+				<key>arguments</key>
+				<dict/>
+			</dict>
+		</dict>
+	</array>
+	<key>connectors</key>
+	<dict>
+		<key>9CB46FF6-D325-4A58-9C66-0E172CDD8E49</key>
+		<dict>
+			<key>from</key>
+			<string>EE488536-99AD-420A-9D27-0E52173C4CE8 - EE488536-99AD-420A-9D27-0E52173C4CE8</string>
+			<key>to</key>
+			<string>E04807B6-24EA-4133-B576-00796E8C6B39 - E04807B6-24EA-4133-B576-00796E8C6B39</string>
+		</dict>
+	</dict>
+	<key>workflowMetaData</key>
+	<dict>
+		<key>workflowTypeIdentifier</key>
+		<string>com.apple.Automator.workflow</string>
+	</dict>
+</dict>
+</plist>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.