src/eric7/Plugins/PluginEricapi.py

branch
eric7
changeset 10315
4102a69604eb
parent 10069
435cc5875135
child 10317
f1b00d7dec16
equal deleted inserted replaced
10314:1f7d52f024b1 10315:4102a69604eb
7 Module implementing the Ericapi plugin. 7 Module implementing the Ericapi plugin.
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt6.QtCore import QCoreApplication, QObject 12 from PyQt6.QtCore import QCoreApplication, QObject, pyqtSlot
13 from PyQt6.QtWidgets import QDialog 13 from PyQt6.QtWidgets import QDialog
14 14
15 from eric7.EricGui.EricAction import EricAction 15 from eric7.EricGui.EricAction import EricAction
16 from eric7.EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 from eric7.Globals import getConfig 17 from eric7.Globals import getConfig
106 def __initialize(self): 106 def __initialize(self):
107 """ 107 """
108 Private slot to (re)initialize the plugin. 108 Private slot to (re)initialize the plugin.
109 """ 109 """
110 self.__projectAct = None 110 self.__projectAct = None
111 self.__execDialog = None
111 112
112 def activate(self): 113 def activate(self):
113 """ 114 """
114 Public method to activate this plugin. 115 Public method to activate this plugin.
115 116
168 in ["Python", "Python3", "Ruby", "MicroPython"] 169 in ["Python", "Python3", "Ruby", "MicroPython"]
169 ) 170 )
170 171
171 def __doEricapi(self): 172 def __doEricapi(self):
172 """ 173 """
173 Private slot to perform the eric7_api api generation. 174 Private slot to perform the eric7_api API generation.
174 """ 175 """
175 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog import ( 176 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog import (
176 EricapiConfigDialog, 177 EricapiConfigDialog,
177 ) 178 )
178 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiExecDialog import ( 179 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiExecDialog import (
197 # add parameter for the eol setting 198 # add parameter for the eol setting
198 if not project.useSystemEol(): 199 if not project.useSystemEol():
199 args.append("--eol={0}".format(eolTranslation[project.getEolString()])) 200 args.append("--eol={0}".format(eolTranslation[project.getEolString()]))
200 201
201 # now do the call 202 # now do the call
202 dia = EricapiExecDialog("Ericapi") 203 self.__execDialog = EricapiExecDialog("Ericapi")
203 res = dia.start(args, startDir) 204 self.__execDialog.finished.connect(self.__execDialogFinished)
204 if res: 205 self.__execDialog.processFinished.connect(self.__ericapiProcessFinished)
205 dia.exec() 206 self.__execDialog.show()
206 207 self.__execDialog.start(args, startDir)
207 outputFileName = FileSystemUtilities.toNativeSeparators(parms["outputFile"]) 208
208 209 @pyqtSlot()
209 # add output files to the project data, if they aren't in already 210 def __ericapiProcessFinished(self):
210 for progLanguage in parms["languages"]: 211 """
211 if "%L" in outputFileName: 212 Private slot to perform actions after the API data was generated.
212 outfile = outputFileName.replace("%L", progLanguage) 213 """
214 project = ericApp().getObject("Project")
215 parms = project.getData("DOCUMENTATIONPARMS", "ERIC4DOC")
216
217 outputFileName = FileSystemUtilities.toNativeSeparators(parms["outputFile"])
218
219 # add output files to the project data, if they aren't in already
220 for progLanguage in parms["languages"]:
221 if "%L" in outputFileName:
222 outfile = outputFileName.replace("%L", progLanguage)
223 else:
224 if len(parms["languages"]) == 1:
225 outfile = outputFileName
213 else: 226 else:
214 if len(parms["languages"]) == 1: 227 root, ext = os.path.splitext(outputFileName)
215 outfile = outputFileName 228 outfile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext)
216 else: 229
217 root, ext = os.path.splitext(outputFileName) 230 outfile = project.getRelativePath(outfile)
218 outfile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext) 231 if outfile not in project.getProjectData(dataKey="OTHERS"):
219 232 project.appendFile(outfile)
220 outfile = project.getRelativePath(outfile) 233
221 if outfile not in project.getProjectData(dataKey="OTHERS"): 234 @pyqtSlot()
222 project.appendFile(outfile) 235 def __execDialogFinished(self):
236 """
237 Private slot to handle the execution dialog being closed.
238 """
239 self.__execDialog = None

eric ide

mercurial