Skip to content
Newer
Older
100644 181 lines (140 sloc) 4.74 KB
eb8e001 @davglass Initial Import of the GUI
authored
1 #
2 # YUIDocGUIAppDelegate.py
3 # YUIDocGUI
4 #
5 # Created by Dav Glass on 6/25/09.
6 # Copyright __MyCompanyName__ 2009. All rights reserved.
7 #
8
9 from objc import YES, NO, IBAction, IBOutlet
10 from Foundation import *
11 from AppKit import *
12 from subprocess import call, PIPE, Popen
cff5254 @davglass First Working version
authored
13 import os
14 from cStringIO import StringIO
eb8e001 @davglass Initial Import of the GUI
authored
15
16
17
18
19 class YUIDocGUIAppDelegate(NSObject):
cff5254 @davglass First Working version
authored
20 myWindow = objc.IBOutlet()
21 textView = objc.IBOutlet()
22 generateButton = objc.IBOutlet()
eb8e001 @davglass Initial Import of the GUI
authored
23 sourcepath = objc.ivar(u"sourcepath")
24 savepath = objc.ivar(u"savepath")
25 tmpPath = '/tmp/yuidoc/'
cff5254 @davglass First Working version
authored
26 project_name = objc.ivar(u"project_name")
27 project_url = objc.ivar(u"project_url")
28 project_version = objc.ivar(u"project_version")
29 generate = objc.ivar(u"generate")
30 showprivate = True
31 _show_private = True
32 _can_start = False
33
34 ext = {
35 'js': True,
36 'as': False,
37 'py': False,
38 'php': False,
39 'pl': False,
40 'rb': False,
41 'cs': False,
42 'java': False
43 }
44
45 def applicationShouldTerminateAfterLastWindowClosed_(self, sender):
46 return True
47
eb8e001 @davglass Initial Import of the GUI
authored
48
49 def applicationDidFinishLaunching_(self, sender):
50 NSLog("Application did finish launching.")
cff5254 @davglass First Working version
authored
51 NSLog("SV: %s" % self.textView)
52 NSLog("generateButton: %s" % self.generateButton)
53 self.textView.insertText_('Logging will appear here.\n')
eb8e001 @davglass Initial Import of the GUI
authored
54
55 @IBAction
cff5254 @davglass First Working version
authored
56 def setextjs_(self, value):
57 self.ext['js'] = value.state()
58
59 @IBAction
60 def setextas_(self, value):
61 self.ext['as'] = value.state()
62
63 @IBAction
64 def setextpy_(self, value):
65 self.ext['py'] = value.state()
66
67 @IBAction
68 def setextphp_(self, value):
69 self.ext['php'] = value.state()
70
71 @IBAction
72 def setextpl_(self, value):
73 self.ext['pl'] = value.state()
74
75 @IBAction
76 def setextrb_(self, value):
77 self.ext['rb'] = value.state()
78
79 @IBAction
80 def setextcs_(self, value):
81 self.ext['cs'] = value.state()
82
83 @IBAction
84 def setextjava_(self, value):
85 self.ext['java'] = value.state()
86
87 @IBAction
88 def setprivate_(self, value):
89 self._show_private = value.state()
90
91 @IBAction
92 def setprojectname_(self, value):
93 self.validate()
94
95 @IBAction
96 def setprojecturl_(self, value):
97 self.validate()
98
99 @IBAction
100 def setprojectversion_(self, value):
101 self.validate()
102
103 @IBAction
104 def setsourcepath_(self, value):
105 self.validate()
106
107 @IBAction
108 def setsavepath_(self, value):
109 self.validate()
110
111 def validate(self):
112 #self.logoutput = 'Logging will show here.'
113 #NSLog("LOG: %s" % self.logoutput)
114 NSLog("VALIDATE: ")
115 self._can_start = False
031bdd0 @davglass Added disabled button support
authored
116 self.generateButton.setEnabled_(False)
cff5254 @davglass First Working version
authored
117 if self.project_version and self.project_name and self.project_url and self.sourcepath and self.savepath:
031bdd0 @davglass Added disabled button support
authored
118 self.generateButton.setEnabled_(True)
cff5254 @davglass First Working version
authored
119 self._can_start = True
120
121
122 NSLog("VALIDATE: %s" % self._can_start)
123
124
125
126 @IBAction
eb8e001 @davglass Initial Import of the GUI
authored
127 def generate_(self, value):
cff5254 @davglass First Working version
authored
128 if not self._can_start:
129 NSBeginInformationalAlertSheet(
130 u"Can not generate docs",
131 u"OK", None, None, self.myWindow, None, None, None, None,
132 u"Please fill in all fields, they are required.."
133 )
134
135 NSLog("Can not start, not enough info")
136 return
137
031bdd0 @davglass Added disabled button support
authored
138 self.textView.insertText_('Doc generation starting, please wait..\n')
139 self.generateButton.setTitle_('Generating..')
cff5254 @davglass First Working version
authored
140
141 ##This is a hack and needs to be fixed..
142 yuidocPath = "%s/YUIDocGUI.app/Contents/Resources/yuidoc" % os.path.abspath('./')
143 templatePath = '%s/template' % yuidocPath
144 ext = []
145 for i in self.ext.keys():
146 if self.ext[i]:
147 ext.append(".%s" % i)
148
149 args = [
150 '%s/bin/yuidoc.py' % yuidocPath,
151 self.sourcepath.path(),
152 '-p', self.tmpPath,
153 '-o', self.savepath.path(),
154 '-t', templatePath,
155 '-v', self.project_version,
156 '-e', ','.join(ext)
157 ]
158 if self._show_private:
159 args.append('-s')
160
161 NSLog("Run: %s" % args)
162 NSLog('Path: %s' % yuidocPath)
163
031bdd0 @davglass Added disabled button support
authored
164 call(args)
cff5254 @davglass First Working version
authored
165 error_file = open('/tmp/yuidoc.log', 'w+')
166
167 logoutput = ''
168 retcode = call(args, stderr=error_file, stdout=error_file)
169 if retcode > 0:
170 logoutput = 'ERROR\n\n'
171
172 f = open('/tmp/yuidoc.log')
173 logoutput = "%s %s" % (logoutput, f.read())
174 NSLog("LOG: %s" % logoutput)
175
031bdd0 @davglass Added disabled button support
authored
176 self.textView.insertText_('%s\nDocs finished..' % logoutput)
cff5254 @davglass First Working version
authored
177 NSLog("Docs finished..")
031bdd0 @davglass Added disabled button support
authored
178 self.generateButton.setTitle_('Generate Docs')
cff5254 @davglass First Working version
authored
179
eb8e001 @davglass Initial Import of the GUI
authored
180
Something went wrong with that request. Please try again.