Skip to content

Commit 7ec28bb

Browse files
committed
make lang part of filenames
1 parent ccecec1 commit 7ec28bb

23 files changed

+46
-42
lines changed

.renameSnippets.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414

1515
# ignore other files than snippets & ignore focus ones
1616
if fileName.startswith("focus_") or not fileName.endswith(".codesnippet"):
17-
continue
17+
continue
1818

1919
# parse snippet file
2020
xmldoc = minidom.parse(fileName)
2121
keyslist = xmldoc.getElementsByTagName('key')
2222
allChilds = xmldoc.getElementsByTagName('dict')[0].childNodes
2323

2424
for x in allChilds:
25-
if not x.firstChild:
26-
allChilds.remove(x)
25+
if not x.firstChild:
26+
allChilds.remove(x)
2727

2828
snippetTitle = None
29+
lang = "objc"
2930

3031
# prase snippet title
3132
for key in keyslist:
32-
value = key.firstChild.nodeValue
33-
if value == "IDECodeSnippetTitle":
34-
snippetTitle = allChilds[allChilds.index(key)+1].firstChild.nodeValue
33+
value = key.firstChild.nodeValue
34+
if value == "IDECodeSnippetTitle":
35+
snippetTitle = allChilds[allChilds.index(key)+1].firstChild.nodeValue
36+
elif value == "IDECodeSnippetLanguage":
37+
if allChilds[allChilds.index(key)+1].firstChild.nodeValue.endswith("Swift"):
38+
lang = "swift"
3539

3640
# if snippet has a title
3741
if snippetTitle is not None:
@@ -41,7 +45,7 @@
4145
allWords = re.findall("[a-zA-Z]+", snippetTitle)
4246
uppercaseWords = map(lambda x: x.title(), allWords)
4347
newName = "".join(uppercaseWords) + ".codesnippet"
44-
newName = first_lower(newName)
48+
newName = lang + "_" + first_lower(newName)
4549

4650
# if name changed, rename file
4751
if not newName == fileName:

README.md

+35-35
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To run this script automatically before each commit, install the pre-commit hook
1818

1919
## Snippet Descriptions
2020

21-
**addAChildViewcontroller.codesnippet** (Add a child ViewController)
21+
**objc_addAChildViewcontroller.codesnippet** (Add a child ViewController)
2222
Language: `Obj-C`
2323
Shortcut: `childController`
2424
Adds a child ViewController to self
@@ -29,7 +29,7 @@ Adds a child ViewController to self
2929
[self.contentView addSubview:newController.view];
3030
[newController didMoveToParentViewController:self];
3131

32-
**createAReusableTablecell.codesnippet** (Create a reusable TableCell)
32+
**objc_createAReusableTablecell.codesnippet** (Create a reusable TableCell)
3333
Language: `Obj-C`
3434
Shortcut: `tablecell`
3535
Initialises / deques a new cell from the tableview using an identifier
@@ -43,14 +43,14 @@ Initialises / deques a new cell from the tableview using an identifier
4343
4444
return cell;
4545

46-
**createAnImageview.codesnippet** (Create an imageView)
46+
**objc_createAnImageview.codesnippet** (Create an imageView)
4747
Language: `Obj-C`
4848
Shortcut: `iv`
4949
Inits a new imageView with an image via imageNamed.
5050

5151
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<#imageName#>"]]
5252

53-
**createAndShowAUialertview.codesnippet** (Create & show a UIAlertView)
53+
**objc_createAndShowAUialertview.codesnippet** (Create & show a UIAlertView)
5454
Language: `Obj-C`
5555
Shortcut: `alertview`
5656
Shows a newly created alertview
@@ -61,7 +61,7 @@ Shows a newly created alertview
6161
cancelButtonTitle:<#nil#>
6262
otherButtonTitles:<#nil#>] show];
6363

64-
**decrementingForLoop.codesnippet** (Decrementing For Loop)
64+
**objc_decrementingForLoop.codesnippet** (Decrementing For Loop)
6565
Language: `Obj-C`
6666
Shortcut: `fori`
6767
A For Loop decrementing a local variable
@@ -70,14 +70,14 @@ A For Loop decrementing a local variable
7070
<#statements#>
7171
}
7272

73-
**formattedString.codesnippet** (Formatted String)
73+
**objc_formattedString.codesnippet** (Formatted String)
7474
Language: `Obj-C`
7575
Shortcut: `format`
7676
Shortcut for a formatted string
7777

7878
[NSString stringWithFormat:@"<#string#>", <#param1#>]
7979

80-
**getDocumentsDirectory.codesnippet** (Get Documents directory)
80+
**objc_getDocumentsDirectory.codesnippet** (Get Documents directory)
8181
Language: `Obj-C`
8282
Shortcut: `documents`
8383
Create path to documents directory
@@ -86,28 +86,21 @@ Create path to documents directory
8686
NSString *documentsDirectory = [paths objectAtIndex:0];
8787
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"<#fileName#>"];
8888

89-
**guardWeakSelf.codesnippet** (Guard Weak Self)
90-
Language: `Swift`
91-
Shortcut: `ws`
92-
Guard weak self to exist
93-
94-
guard let self = self else { return <#returnValue#> }
95-
96-
**importFramework.codesnippet** (Import Framework)
89+
**objc_importFramework.codesnippet** (Import Framework)
9790
Language: `Obj-C`
9891
Shortcut: `imp2`
9992
import a framework
10093

10194
#import <<#header#>>
10295

103-
**importHeader.codesnippet** (Import header)
96+
**objc_importHeader.codesnippet** (Import header)
10497
Language: `Obj-C`
10598
Shortcut: `imp1`
10699
Import a header
107100

108101
#import "<#header#>"
109102

110-
**incrementingForLoop.codesnippet** (Incrementing For Loop)
103+
**objc_incrementingForLoop.codesnippet** (Incrementing For Loop)
111104
Language: `Obj-C`
112105
Shortcut: `fori`
113106
A For loop incrementing a local variable
@@ -116,59 +109,50 @@ A For loop incrementing a local variable
116109
<#statements#>
117110
}
118111

119-
**initalizeAnObject.codesnippet** (Initalize an object)
112+
**objc_initalizeAnObject.codesnippet** (Initalize an object)
120113
Language: `Obj-C`
121114
Shortcut: `alloc`
122115
creates a new object from a given class
123116

124117
<#ClassName#> *<#variableName#> = [[<#ClassName#> alloc] init];
125118

126-
**keyValuePairForLocalization.codesnippet** (Key-Value Pair for Localization)
119+
**objc_keyValuePairForLocalization.codesnippet** (Key-Value Pair for Localization)
127120
Language: `Obj-C`
128121
Shortcut: `key`
129122
A localization key and its value
130123

131124
"<#keyName#>" = "<#value#>";
132125

133-
**localizeAString.codesnippet** (Localize a string)
126+
**objc_localizeAString.codesnippet** (Localize a string)
134127
Language: `Obj-C`
135128
Shortcut: `loca`
136129
Localizes a string from a given key
137130

138131
NSLocalizedString(@"<#keyName#>", nil)
139132

140-
**pragmaMark.codesnippet** (Pragma mark)
133+
**objc_pragmaMark.codesnippet** (Pragma mark)
141134
Language: `Obj-C`
142135
Shortcut: `pragma`
143136
Add a new pragma mark
144137

145138
#pragma mark <#comment#>
146139

147-
**pushAViewcontroller.codesnippet** (Push a ViewController)
140+
**objc_pushAViewcontroller.codesnippet** (Push a ViewController)
148141
Language: `Obj-C`
149142
Shortcut: `push`
150143
Pushes a newly created ViewController on the current NavigationController
151144

152145
<#UIViewController#>* viewController = [[<#UIViewController#> alloc] init];
153146
[self.navigationController pushViewController:viewController animated:YES];
154147

155-
**setupAutoresizingOfAView.codesnippet** (Setup autoresizing of a view)
148+
**objc_setupAutoresizingOfAView.codesnippet** (Setup autoresizing of a view)
156149
Language: `Obj-C`
157150
Shortcut: `autoresizing`
158151
Set the autoresizing flags of a view
159152

160153
<#view#>.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
161154

162-
**setupCustomWindowAndVc.codesnippet** (Setup custom window & VC)
163-
Language: `Swift`
164-
Shortcut: `setwin`
165-
Create window and rootVC
166-
167-
window = UIWindow(windowScene: scene)
168-
window?.rootViewController = UINavigationController(rootViewController: <#ViewController#>)
169-
window?.makeKeyAndVisible()
170-
171-
**singleton.codesnippet** (singleton)
155+
**objc_singleton.codesnippet** (singleton)
172156
Language: `Obj-C`
173157
Shortcut: `singleton`
174158
A singleton implementation using dispatch_once
@@ -183,17 +167,33 @@ A singleton implementation using dispatch_once
183167
return _sharedInstance;
184168
}
185169

186-
**strongSelfPointer.codesnippet** (Strong self pointer)
170+
**objc_strongSelfPointer.codesnippet** (Strong self pointer)
187171
Language: `Obj-C`
188172
Shortcut: `ss`
189173
A strong pointer to self (for usage in blocks).
190174

191175
__strong __typeof(weakSelf) strongSelf = weakSelf;
192176

193-
**weakSelfPointer.codesnippet** (Weak self pointer)
177+
**objc_weakSelfPointer.codesnippet** (Weak self pointer)
194178
Language: `Obj-C`
195179
Shortcut: `ws`
196180
A weak pointer to self (for usage in blocks).
197181

198182
__weak __typeof(self) weakSelf = self;
199183

184+
**swift_guardWeakSelf.codesnippet** (Guard Weak Self)
185+
Language: `Swift`
186+
Shortcut: `ws`
187+
Guard weak self to exist
188+
189+
guard let self = self else { return <#returnValue#> }
190+
191+
**swift_setupCustomWindowAndVc.codesnippet** (Setup custom window & VC)
192+
Language: `Swift`
193+
Shortcut: `setwin`
194+
Create window and rootVC
195+
196+
window = UIWindow(windowScene: scene)
197+
window?.rootViewController = UINavigationController(rootViewController: <#ViewController#>)
198+
window?.makeKeyAndVisible()
199+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)