-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApiGen.py
92 lines (75 loc) · 2.92 KB
/
ApiGen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import sys, os
import sublime, sublime_plugin
import ApiGen.ApiGenHelper as ag
class ApiGenShowConsoleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().run_command("show_panel", {"panel": 'console'})
ag.startLine()
class ApiGenBaseClass(sublime_plugin.TextCommand):
def is_enabled(self):
return ag.canRun()
class ApiGenSelfupdateCommand(ApiGenBaseClass):
def run(self, edit):
self.view.run_command('api_gen_show_console')
ag.activate()
args = ['selfupdate']
sublime.set_timeout_async(lambda : ag.runApiGen(args), 0)
class ApiGenVersionCommand(ApiGenBaseClass):
def run(self, edit):
self.view.run_command('api_gen_show_console')
ag.activate()
args = ['-v']
sublime.set_timeout_async(lambda : ag.runApiGen(args), 0)
class ApiGenGenerateCommand(ApiGenBaseClass):
def run(self, edit):
path = self.view.file_name()
if path == None:
return
ag.activate()
self.view.run_command('api_gen_show_console')
config = ag.getConfigFile(path)
if config != '':
print('Processing will proceed using ' + config)
args = ['generate', '--config', config]
additionalArgs = ag.settings.get('additionalGenerateArgs', [])
args.extend(additionalArgs)
sublime.set_timeout_async(lambda : ag.runApiGen(args), 0)
else:
print('No config file could not be found!')
ag.endLine()
ag.deactivate()
class ApiGenFreeformCommand(ApiGenBaseClass):
def run(self, edit):
ag.activate()
window = self.view.window()
window.show_input_panel('ApiGen Arguments', '', self.done, None, self.cancel)
def done(self, args):
self.view.run_command('api_gen_show_console')
args = [args]
sublime.set_timeout_async(lambda : ag.runApiGen(args), 0)
def cancel(self):
ag.deactivate()
class ApiGenGenerateFreeformCommand(ApiGenBaseClass):
def run(self, edit):
ag.activate()
window = self.view.window()
window.show_input_panel('ApiGen Arguments', '', self.done, None, self.cancel)
def done(self, args):
path = self.view.file_name()
if path == None:
return
ag.activate()
self.view.run_command('api_gen_show_console')
config = ag.getConfigFile(path)
if config != '':
print('Processing will proceed using ' + config)
args = ['generate', '--config', config, args]
additionalArgs = ag.settings.get('additionalGenerateArgs', [])
args.extend(additionalArgs)
sublime.set_timeout_async(lambda : ag.runApiGen(args), 0)
else:
print('No config file could not be found!')
ag.endLine()
ag.deactivate()
def cancel(self):
ag.deactivate()