74 ): |
74 ): |
75 exe_ = os.path.join(exepath, exe) |
75 exe_ = os.path.join(exepath, exe) |
76 if os.path.exists(exe_): |
76 if os.path.exists(exe_): |
77 exe = exe_ |
77 exe = exe_ |
78 break |
78 break |
79 |
79 |
80 dataList.append({ |
80 dataList.append( |
81 "programEntry": True, |
81 { |
82 "header": QCoreApplication.translate( |
82 "programEntry": True, |
83 "EricdocPlugin", "eric Documentation Generator"), |
83 "header": QCoreApplication.translate( |
84 "exe": exe, |
84 "EricdocPlugin", "eric Documentation Generator" |
85 "versionCommand": '--version', |
85 ), |
86 "versionStartsWith": 'eric7_', |
86 "exe": exe, |
87 "versionPosition": -3, |
87 "versionCommand": "--version", |
88 "version": "", |
88 "versionStartsWith": "eric7_", |
89 "versionCleanup": None, |
89 "versionPosition": -3, |
90 }) |
90 "version": "", |
91 |
91 "versionCleanup": None, |
|
92 } |
|
93 ) |
|
94 |
92 # 2. Qt Help Generator |
95 # 2. Qt Help Generator |
93 # 2.1 location before 6.3 (Linux and macOS) and Windows |
96 # 2.1 location before 6.3 (Linux and macOS) and Windows |
94 exe = os.path.join( |
97 exe = os.path.join( |
95 Utilities.getQtBinariesPath(), |
98 Utilities.getQtBinariesPath(), Utilities.generateQtToolName("qhelpgenerator") |
96 Utilities.generateQtToolName('qhelpgenerator') |
|
97 ) |
99 ) |
98 if Utilities.isWindowsPlatform(): |
100 if Utilities.isWindowsPlatform(): |
99 exe += '.exe' |
101 exe += ".exe" |
100 if os.path.exists(exe): |
102 if os.path.exists(exe): |
101 dataList.append({ |
103 dataList.append( |
102 "programEntry": True, |
104 { |
103 "header": QCoreApplication.translate( |
105 "programEntry": True, |
104 "EricdocPlugin", "Qt Help Tools"), |
106 "header": QCoreApplication.translate("EricdocPlugin", "Qt Help Tools"), |
105 "exe": exe, |
107 "exe": exe, |
106 "versionCommand": '-v', |
108 "versionCommand": "-v", |
107 "versionStartsWith": 'Qt', |
109 "versionStartsWith": "Qt", |
108 "versionPosition": -1, |
110 "versionPosition": -1, |
109 "version": "", |
111 "version": "", |
110 "versionCleanup": (0, -1), |
112 "versionCleanup": (0, -1), |
111 }) |
113 } |
|
114 ) |
112 else: |
115 else: |
113 # 2.2 location starting with 6.3.0 (Linux and macOS) |
116 # 2.2 location starting with 6.3.0 (Linux and macOS) |
114 exe = os.path.join( |
117 exe = os.path.join( |
115 Utilities.getQtBinariesPath(libexec=True), |
118 Utilities.getQtBinariesPath(libexec=True), |
116 Utilities.generateQtToolName('qhelpgenerator') |
119 Utilities.generateQtToolName("qhelpgenerator"), |
117 ) |
120 ) |
118 dataList.append({ |
121 dataList.append( |
119 "programEntry": True, |
122 { |
120 "header": QCoreApplication.translate( |
123 "programEntry": True, |
121 "EricdocPlugin", "Qt Help Tools"), |
124 "header": QCoreApplication.translate("EricdocPlugin", "Qt Help Tools"), |
122 "exe": exe, |
125 "exe": exe, |
123 "versionCommand": '-v', |
126 "versionCommand": "-v", |
124 "versionStartsWith": 'Qt', |
127 "versionStartsWith": "Qt", |
125 "versionPosition": -1, |
128 "versionPosition": -1, |
126 "version": "", |
129 "version": "", |
127 "versionCleanup": (0, -1), |
130 "versionCleanup": (0, -1), |
128 }) |
131 } |
129 |
132 ) |
|
133 |
130 return dataList |
134 return dataList |
131 |
135 |
132 |
136 |
133 class EricdocPlugin(QObject): |
137 class EricdocPlugin(QObject): |
134 """ |
138 """ |
135 Class implementing the Ericdoc plugin. |
139 Class implementing the Ericdoc plugin. |
136 """ |
140 """ |
|
141 |
137 def __init__(self, ui): |
142 def __init__(self, ui): |
138 """ |
143 """ |
139 Constructor |
144 Constructor |
140 |
145 |
141 @param ui reference to the user interface object (UI.UserInterface) |
146 @param ui reference to the user interface object (UI.UserInterface) |
142 """ |
147 """ |
143 super().__init__(ui) |
148 super().__init__(ui) |
144 self.__ui = ui |
149 self.__ui = ui |
145 self.__initialize() |
150 self.__initialize() |
146 |
151 |
147 def __initialize(self): |
152 def __initialize(self): |
148 """ |
153 """ |
149 Private slot to (re)initialize the plugin. |
154 Private slot to (re)initialize the plugin. |
150 """ |
155 """ |
151 self.__projectAct = None |
156 self.__projectAct = None |
152 |
157 |
153 def activate(self): |
158 def activate(self): |
154 """ |
159 """ |
155 Public method to activate this plugin. |
160 Public method to activate this plugin. |
156 |
161 |
157 @return tuple of None and activation status (boolean) |
162 @return tuple of None and activation status (boolean) |
158 """ |
163 """ |
159 menu = ericApp().getObject("Project").getMenu("Apidoc") |
164 menu = ericApp().getObject("Project").getMenu("Apidoc") |
160 if menu: |
165 if menu: |
161 self.__projectAct = EricAction( |
166 self.__projectAct = EricAction( |
162 self.tr('Generate documentation (eric7_doc)'), |
167 self.tr("Generate documentation (eric7_doc)"), |
163 self.tr('Generate &documentation (eric7_doc)'), 0, 0, |
168 self.tr("Generate &documentation (eric7_doc)"), |
164 self, 'doc_eric7_doc') |
169 0, |
|
170 0, |
|
171 self, |
|
172 "doc_eric7_doc", |
|
173 ) |
165 self.__projectAct.setStatusTip( |
174 self.__projectAct.setStatusTip( |
166 self.tr('Generate API documentation using eric7_doc')) |
175 self.tr("Generate API documentation using eric7_doc") |
167 self.__projectAct.setWhatsThis(self.tr( |
176 ) |
168 """<b>Generate documentation</b>""" |
177 self.__projectAct.setWhatsThis( |
169 """<p>Generate API documentation using eric7_doc.</p>""" |
178 self.tr( |
170 )) |
179 """<b>Generate documentation</b>""" |
|
180 """<p>Generate API documentation using eric7_doc.</p>""" |
|
181 ) |
|
182 ) |
171 self.__projectAct.triggered.connect(self.__doEricdoc) |
183 self.__projectAct.triggered.connect(self.__doEricdoc) |
172 ericApp().getObject("Project").addEricActions([self.__projectAct]) |
184 ericApp().getObject("Project").addEricActions([self.__projectAct]) |
173 menu.addAction(self.__projectAct) |
185 menu.addAction(self.__projectAct) |
174 |
186 |
175 ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu) |
187 ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu) |
176 |
188 |
177 return None, True |
189 return None, True |
178 |
190 |
179 def deactivate(self): |
191 def deactivate(self): |
180 """ |
192 """ |
181 Public method to deactivate this plugin. |
193 Public method to deactivate this plugin. |
182 """ |
194 """ |
183 ericApp().getObject("Project").showMenu.disconnect( |
195 ericApp().getObject("Project").showMenu.disconnect(self.__projectShowMenu) |
184 self.__projectShowMenu) |
196 |
185 |
|
186 menu = ericApp().getObject("Project").getMenu("Apidoc") |
197 menu = ericApp().getObject("Project").getMenu("Apidoc") |
187 if menu: |
198 if menu: |
188 menu.removeAction(self.__projectAct) |
199 menu.removeAction(self.__projectAct) |
189 ericApp().getObject("Project").removeEricActions( |
200 ericApp().getObject("Project").removeEricActions([self.__projectAct]) |
190 [self.__projectAct]) |
|
191 self.__initialize() |
201 self.__initialize() |
192 |
202 |
193 def __projectShowMenu(self, menuName, menu): |
203 def __projectShowMenu(self, menuName, menu): |
194 """ |
204 """ |
195 Private slot called, when the the project menu or a submenu is |
205 Private slot called, when the the project menu or a submenu is |
196 about to be shown. |
206 about to be shown. |
197 |
207 |
198 @param menuName name of the menu to be shown (string) |
208 @param menuName name of the menu to be shown (string) |
199 @param menu reference to the menu (QMenu) |
209 @param menu reference to the menu (QMenu) |
200 """ |
210 """ |
201 if menuName == "Apidoc" and self.__projectAct is not None: |
211 if menuName == "Apidoc" and self.__projectAct is not None: |
202 self.__projectAct.setEnabled( |
212 self.__projectAct.setEnabled( |
203 ericApp().getObject("Project").getProjectLanguage() in |
213 ericApp().getObject("Project").getProjectLanguage() |
204 ["Python", "Python3", "Ruby", "MicroPython"]) |
214 in ["Python", "Python3", "Ruby", "MicroPython"] |
205 |
215 ) |
|
216 |
206 def __doEricdoc(self): |
217 def __doEricdoc(self): |
207 """ |
218 """ |
208 Private slot to perform the eric7_doc api documentation generation. |
219 Private slot to perform the eric7_doc api documentation generation. |
209 """ |
220 """ |
210 from DocumentationPlugins.Ericdoc.EricdocConfigDialog import ( |
221 from DocumentationPlugins.Ericdoc.EricdocConfigDialog import EricdocConfigDialog |
211 EricdocConfigDialog |
222 |
212 ) |
|
213 eolTranslation = { |
223 eolTranslation = { |
214 '\r': 'cr', |
224 "\r": "cr", |
215 '\n': 'lf', |
225 "\n": "lf", |
216 '\r\n': 'crlf', |
226 "\r\n": "crlf", |
217 } |
227 } |
218 project = ericApp().getObject("Project") |
228 project = ericApp().getObject("Project") |
219 parms = project.getData('DOCUMENTATIONPARMS', "ERIC4DOC") |
229 parms = project.getData("DOCUMENTATIONPARMS", "ERIC4DOC") |
220 dlg = EricdocConfigDialog(project, parms) |
230 dlg = EricdocConfigDialog(project, parms) |
221 if dlg.exec() == QDialog.DialogCode.Accepted: |
231 if dlg.exec() == QDialog.DialogCode.Accepted: |
222 args, parms, startDir = dlg.generateParameters() |
232 args, parms, startDir = dlg.generateParameters() |
223 project.setData('DOCUMENTATIONPARMS', "ERIC4DOC", parms) |
233 project.setData("DOCUMENTATIONPARMS", "ERIC4DOC", parms) |
224 |
234 |
225 if not startDir: |
235 if not startDir: |
226 startDir = project.ppath |
236 startDir = project.ppath |
227 |
237 |
228 # add parameter for the eol setting |
238 # add parameter for the eol setting |
229 if not project.useSystemEol(): |
239 if not project.useSystemEol(): |
230 args.append( |
240 args.append("--eol={0}".format(eolTranslation[project.getEolString()])) |
231 "--eol={0}".format(eolTranslation[project.getEolString()])) |
241 |
232 |
|
233 # now do the call |
242 # now do the call |
234 from DocumentationPlugins.Ericdoc.EricdocExecDialog import ( |
243 from DocumentationPlugins.Ericdoc.EricdocExecDialog import EricdocExecDialog |
235 EricdocExecDialog |
244 |
236 ) |
|
237 dia = EricdocExecDialog("Ericdoc") |
245 dia = EricdocExecDialog("Ericdoc") |
238 res = dia.start(args, startDir) |
246 res = dia.start(args, startDir) |
239 if res: |
247 if res: |
240 dia.exec() |
248 dia.exec() |
241 |
249 |
242 outdir = Utilities.toNativeSeparators(parms['outputDirectory']) |
250 outdir = Utilities.toNativeSeparators(parms["outputDirectory"]) |
243 if outdir == '': |
251 if outdir == "": |
244 outdir = 'doc' # that is eric7_docs default output dir |
252 outdir = "doc" # that is eric7_docs default output dir |
245 |
253 |
246 # add it to the project data, if it isn't in already |
254 # add it to the project data, if it isn't in already |
247 outdir = project.getRelativePath(outdir) |
255 outdir = project.getRelativePath(outdir) |
248 if outdir not in project.pdata['OTHERS']: |
256 if outdir not in project.pdata["OTHERS"]: |
249 project.pdata['OTHERS'].append(outdir) |
257 project.pdata["OTHERS"].append(outdir) |
250 project.setDirty(True) |
258 project.setDirty(True) |
251 project.othersAdded(outdir) |
259 project.othersAdded(outdir) |
252 |
260 |
253 if parms['qtHelpEnabled']: |
261 if parms["qtHelpEnabled"]: |
254 outdir = Utilities.toNativeSeparators( |
262 outdir = Utilities.toNativeSeparators(parms["qtHelpOutputDirectory"]) |
255 parms['qtHelpOutputDirectory']) |
263 if outdir == "": |
256 if outdir == '': |
264 outdir = "help" |
257 outdir = 'help' |
|
258 # that is eric7_docs default QtHelp output dir |
265 # that is eric7_docs default QtHelp output dir |
259 |
266 |
260 # add it to the project data, if it isn't in already |
267 # add it to the project data, if it isn't in already |
261 outdir = project.getRelativePath(outdir) |
268 outdir = project.getRelativePath(outdir) |
262 if outdir not in project.pdata['OTHERS']: |
269 if outdir not in project.pdata["OTHERS"]: |
263 project.pdata['OTHERS'].append(outdir) |
270 project.pdata["OTHERS"].append(outdir) |
264 project.setDirty(True) |
271 project.setDirty(True) |
265 project.othersAdded(outdir) |
272 project.othersAdded(outdir) |