Plugins/PluginEricapi.py

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

eric ide

mercurial