Plugins/PluginEricapi.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2791
a9577f248f04
parent 3004
c4bf32c791d0
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
30 version = "5.4.0" 30 version = "5.4.0"
31 className = "EricapiPlugin" 31 className = "EricapiPlugin"
32 packageName = "__core__" 32 packageName = "__core__"
33 shortDescription = "Show the Ericapi dialogs." 33 shortDescription = "Show the Ericapi dialogs."
34 longDescription = """This plugin implements the Ericapi dialogs.""" \ 34 longDescription = """This plugin implements the Ericapi dialogs.""" \
35 """ Ericapi is used to generate a QScintilla API file for Python and Ruby projects.""" 35 """ Ericapi is used to generate a QScintilla API file for Python and Ruby"""\
36 """ projects."""
36 pyqtApi = 2 37 pyqtApi = 2
37 # End-Of-Header 38 # End-Of-Header
38 39
39 error = "" 40 error = ""
40 41
91 92
92 @return tuple of None and activation status (boolean) 93 @return tuple of None and activation status (boolean)
93 """ 94 """
94 menu = e5App().getObject("Project").getMenu("Apidoc") 95 menu = e5App().getObject("Project").getMenu("Apidoc")
95 if menu: 96 if menu:
96 self.__projectAct = E5Action(self.trUtf8('Generate API file (eric5_api)'), 97 self.__projectAct = E5Action(
97 self.trUtf8('Generate &API file (eric5_api)'), 0, 0, 98 self.trUtf8('Generate API file (eric5_api)'),
98 self, 'doc_eric5_api') 99 self.trUtf8('Generate &API file (eric5_api)'), 0, 0,
99 self.__projectAct.setStatusTip( 100 self, 'doc_eric5_api')
100 self.trUtf8('Generate an API file using eric5_api')) 101 self.__projectAct.setStatusTip(self.trUtf8(
102 'Generate an API file using eric5_api'))
101 self.__projectAct.setWhatsThis(self.trUtf8( 103 self.__projectAct.setWhatsThis(self.trUtf8(
102 """<b>Generate API file</b>""" 104 """<b>Generate API file</b>"""
103 """<p>Generate an API file using eric5_api.</p>""" 105 """<p>Generate an API file using eric5_api.</p>"""
104 )) 106 ))
105 self.__projectAct.triggered[()].connect(self.__doEricapi) 107 self.__projectAct.triggered[()].connect(self.__doEricapi)
112 114
113 def deactivate(self): 115 def deactivate(self):
114 """ 116 """
115 Public method to deactivate this plugin. 117 Public method to deactivate this plugin.
116 """ 118 """
117 e5App().getObject("Project").showMenu.disconnect(self.__projectShowMenu) 119 e5App().getObject("Project").showMenu.disconnect(
120 self.__projectShowMenu)
118 121
119 menu = e5App().getObject("Project").getMenu("Apidoc") 122 menu = e5App().getObject("Project").getMenu("Apidoc")
120 if menu: 123 if menu:
121 menu.removeAction(self.__projectAct) 124 menu.removeAction(self.__projectAct)
122 e5App().getObject("Project").removeE5Actions([self.__projectAct]) 125 e5App().getObject("Project").removeE5Actions([self.__projectAct])
138 141
139 def __doEricapi(self): 142 def __doEricapi(self):
140 """ 143 """
141 Private slot to perform the eric5_api api generation. 144 Private slot to perform the eric5_api api generation.
142 """ 145 """
143 from DocumentationPlugins.Ericapi.EricapiConfigDialog import EricapiConfigDialog 146 from DocumentationPlugins.Ericapi.EricapiConfigDialog import \
147 EricapiConfigDialog
144 eolTranslation = { 148 eolTranslation = {
145 '\r': 'cr', 149 '\r': 'cr',
146 '\n': 'lf', 150 '\n': 'lf',
147 '\r\n': 'crlf', 151 '\r\n': 'crlf',
148 } 152 }
153 args, parms = dlg.generateParameters() 157 args, parms = dlg.generateParameters()
154 project.setData('DOCUMENTATIONPARMS', "ERIC4API", parms) 158 project.setData('DOCUMENTATIONPARMS', "ERIC4API", parms)
155 159
156 # add parameter for the eol setting 160 # add parameter for the eol setting
157 if not project.useSystemEol(): 161 if not project.useSystemEol():
158 args.append("--eol={0}".format(eolTranslation[project.getEolString()])) 162 args.append(
163 "--eol={0}".format(eolTranslation[project.getEolString()]))
159 164
160 # now do the call 165 # now do the call
161 from DocumentationPlugins.Ericapi.EricapiExecDialog import EricapiExecDialog 166 from DocumentationPlugins.Ericapi.EricapiExecDialog import \
167 EricapiExecDialog
162 dia = EricapiExecDialog("Ericapi") 168 dia = EricapiExecDialog("Ericapi")
163 res = dia.start(args, project.ppath) 169 res = dia.start(args, project.ppath)
164 if res: 170 if res:
165 dia.exec_() 171 dia.exec_()
166 172
173 else: 179 else:
174 if len(parms['languages']) == 1: 180 if len(parms['languages']) == 1:
175 outfile = outputFileName 181 outfile = outputFileName
176 else: 182 else:
177 root, ext = os.path.splitext(outputFileName) 183 root, ext = os.path.splitext(outputFileName)
178 outfile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext) 184 outfile = "{0}-{1}{2}".format(
185 root, progLanguage.lower(), ext)
179 186
180 outfile = project.getRelativePath(outfile) 187 outfile = project.getRelativePath(outfile)
181 if outfile not in project.pdata['OTHERS']: 188 if outfile not in project.pdata['OTHERS']:
182 project.pdata['OTHERS'].append(outfile) 189 project.pdata['OTHERS'].append(outfile)
183 project.setDirty(True) 190 project.setDirty(True)

eric ide

mercurial