Permalink
Browse files

added script, to describe snippets in markdown, updated readme with d…

…escriptions
  • Loading branch information...
1 parent f2fa77c commit e844e7adc4bad6496f3c3d345971eb9df32503e5 @calimarkus committed Feb 13, 2013
Showing with 137 additions and 1 deletion.
  1. +43 −0 .generateDescription.py
  2. +94 −1 README.md
View
@@ -0,0 +1,43 @@
+from xml.dom import minidom
+import os
+import glob
+
+file = open('description.md', 'w')
+file.write('## Snippet Descriptions\n\n(generated with .generateDescription.py)\n\n')
+
+listing = os.listdir(".")
+for fileName in listing:
+
+ if not fileName.endswith(".codesnippet"):
+ continue
+
+ xmldoc = minidom.parse(fileName)
+ keyslist = xmldoc.getElementsByTagName('key')
+ allChilds = xmldoc.getElementsByTagName('dict')[0].childNodes
+
+ for x in allChilds:
+ if not x.firstChild:
+ allChilds.remove(x)
+
+ title=""
+ summary=""
+ shortcut=""
+ contents=""
+
+ for key in keyslist:
+ value = key.firstChild.nodeValue
+ if (value == "IDECodeSnippetCompletionPrefix"):
+ shortcut = allChilds[allChilds.index(key)+1].firstChild.nodeValue
+ elif value == "IDECodeSnippetContents":
+ contents = allChilds[allChilds.index(key)+1].firstChild.nodeValue
+ elif value == "IDECodeSnippetSummary":
+ summary = allChilds[allChilds.index(key)+1].firstChild.nodeValue
+ elif value == "IDECodeSnippetTitle":
+ title = allChilds[allChilds.index(key)+1].firstChild.nodeValue
+
+ file.write('**' + fileName + '** (' + title + ') \n')
+ file.write('Shortcut: `' + shortcut + '` \n')
+ file.write(summary + '\n\n')
+ file.write(' ' + contents.replace('\n', '\n ') + '\n\n')
+
+file.close()
View
@@ -4,4 +4,97 @@ These are my Xcode 4 CodeSnippets. Just check them out into the following path:
`~/Library/Developer/Xcode/UserData/CodeSnippets`
-And you're ready to go.
+And you're ready to go.
+
+## Snippet Descriptions
+
+(created with .generateDescription.py)
+
+
+**allocInit.codesnippet** (Initalize an object)
+Shortcut: `alloc`
+creates a new object from a given class
+
+ <#ClassName#> *<#variableName#> = [[<#ClassName#> alloc] init];
+
+**autoresizingMask.codesnippet** (Setup autoresizing of a view)
+Shortcut: `autoresizing`
+Set the autoresizing flags of a view
+
+ <#view#>.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+
+**dequeueTableCell.codesnippet** (Create a reusable TableCell)
+Shortcut: `tablecell`
+Initialises / deques a new cell from the tableview using an identifier
+
+ // create / dequeue cell
+ static NSString* identifier = @"<#identifier#>";
+ UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:identifier];
+ if (cell == nil) {
+ cell = [[<#UITableViewCell#> alloc] initWithStyle:<#UITableViewCellStyleSubtitle#> reuseIdentifier:identifier];
+ }
+
+ return cell;
+
+**fori-loop.codesnippet** (Incrementing For Loop)
+Shortcut: `fori`
+A For loop incrementing a local variable
+
+ for (NSInteger i=0; i<<#count#>; i++) {
+ <#statements#>
+ }
+
+**importFramework.codesnippet** (Import Framework)
+Shortcut: `imp2`
+import a framework
+
+ #import <<#header#>>
+
+**importHeader.codesnippet** (Import header)
+Shortcut: `imp1`
+Import a header
+
+ #import "<#header#>"
+
+**Localizable-keyValue.codesnippet** (Key-Value Pair for Localization)
+Shortcut: `key`
+A localization key and its value
+
+ "<#keyName#>" = "<#value#>";
+
+**NSLocalizedString.codesnippet** (Localize a string)
+Shortcut: `loca`
+Localizes a string from a given key
+
+ NSLocalizedString(@"<#keyName#>", nil)
+
+**pragma-mark.codesnippet** (Pragma mark)
+Shortcut: `pragma`
+Add a new pragma mark
+
+ #pragma mark <#comment#>
+
+**presentAlertView.codesnippet** (Create & show a UIAlertView)
+Shortcut: `alertview`
+Shows a newly created alertview
+
+ UIAlertView* alertView = [[UIAlertView alloc] initWithTitle: <#title#>
+ message: <#message#>
+ delegate: <#self#>
+ cancelButtonTitle: <#nil#>
+ otherButtonTitles: <#@"OK"#>, nil];
+ [alertView show];
+
+**pushController.codesnippet** (Push a ViewController)
+Shortcut: `push`
+Pushes a newly created ViewController on the current NavigationController
+
+ <#UIViewController#>* viewController = [[<#UIViewController#> alloc] init];
+ [self.navigationController pushViewController:viewController animated:YES];
+
+**stringWithFormat.codesnippet** (Format a string)
+Shortcut: `format`
+Formats a string
+
+ [NSString stringWithFormat: @"<#formatString#>"]
+

0 comments on commit e844e7a

Please sign in to comment.