src/eric7/Plugins/PluginEricapi.py

Thu, 16 Nov 2023 16:45:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 16 Nov 2023 16:45:23 +0100
branch
eric7
changeset 10315
4102a69604eb
parent 10069
435cc5875135
child 10317
f1b00d7dec16
permissions
-rw-r--r--

Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9624
diff changeset
3 # Copyright (c) 2007 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Ericapi plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
12 from PyQt6.QtCore import QCoreApplication, QObject, pyqtSlot
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
13 from PyQt6.QtWidgets import QDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
15 from eric7.EricGui.EricAction import EricAction
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9448
diff changeset
16 from eric7.EricWidgets.EricApplication import ericApp
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9448
diff changeset
17 from eric7.Globals import getConfig
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9514
diff changeset
18 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
19 from eric7.UI import Info
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 # Start-Of-Header
10061
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
22 __header__ = {
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
23 "name": "Ericapi Plugin",
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
24 "author": "Detlev Offenbach <detlev@die-offenbachs.de>",
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
25 "autoactivate": True,
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
26 "deactivateable": True,
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
27 "version": Info.VersionOnly,
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
28 "className": "EricapiPlugin",
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
29 "packageName": "__core__",
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
30 "shortDescription": "Show the Ericapi dialogs.",
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
31 "longDescription": (
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
32 """This plugin implements the Ericapi dialogs."""
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
33 """ Ericapi is used to generate a QScintilla API file for Python and"""
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
34 """ Ruby projects."""
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
35 ),
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
36 "pyqtApi": 2,
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
37 }
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 # End-Of-Header
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
10061
8bdad5699288 Introduced a new style for the plugin header.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
40 error = "" # noqa: U200
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
42
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def exeDisplayData():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Public method to support the display of some executable info.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
46
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @return dictionary containing the data to query the presence of
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 the executable
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
50 exe = "eric7_api"
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9514
diff changeset
51 if OSUtilities.isWindowsPlatform():
9138
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
52 for exepath in (
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
53 getConfig("bindir"),
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9514
diff changeset
54 PythonUtilities.getPythonScriptsDirectory(),
9138
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
55 ):
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
56 found = False
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
57 for ext in (".exe", ".cmd", ".bat"):
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
58 exe_ = os.path.join(exepath, exe + ext)
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
59 if os.path.exists(exe_):
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
60 exe = exe_
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
61 found = True
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
62 break
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
63 if found:
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
64 break
6217
35b9e03ffcd6 eric api, eric doc plug-ins: changed the executable path on non-Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
65 else:
9138
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
66 for exepath in (
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
67 getConfig("bindir"),
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9514
diff changeset
68 PythonUtilities.getPythonScriptsDirectory(),
9138
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
69 ):
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
70 exe_ = os.path.join(exepath, exe)
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
71 if os.path.exists(exe_):
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
72 exe = exe_
85f68ca14a7a Fixed an issue detecting the eric api and eric documentation tools when installed via the wheel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
73 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
74
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 data = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
76 "programEntry": True,
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
77 "header": QCoreApplication.translate(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
78 "EricapiPlugin", "eric API File Generator"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
79 ),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
80 "exe": exe,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
81 "versionCommand": "--version",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
82 "versionStartsWith": "eric7_",
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
83 "versionPosition": -3,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
84 "version": "",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
85 "versionCleanup": None,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
87
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 return data
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
90
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 class EricapiPlugin(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 Class implementing the Ericapi plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
95
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def __init__(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
99
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param ui reference to the user interface object (UI.UserInterface)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
102 super().__init__(ui)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.__ui = ui
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.__initialize()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
105
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __initialize(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private slot to (re)initialize the plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__projectAct = None
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
111 self.__execDialog = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 def activate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 Public method to activate this plugin.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
116
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @return tuple of None and activation status (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
119 menu = ericApp().getObject("Project").getMenu("Apidoc")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if menu:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
121 self.__projectAct = EricAction(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
122 self.tr("Generate API file (eric7_api)"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
123 self.tr("Generate &API file (eric7_api)"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
124 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
125 0,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
126 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
127 "doc_eric7_api",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
128 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
129 self.__projectAct.setStatusTip(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
130 self.tr("Generate an API file using eric7_api")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
131 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
132 self.__projectAct.setWhatsThis(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
133 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
134 """<b>Generate API file</b>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
135 """<p>Generate an API file using eric7_api.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
136 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
137 )
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
138 self.__projectAct.triggered.connect(self.__doEricapi)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
139 ericApp().getObject("Project").addEricActions([self.__projectAct])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 menu.addAction(self.__projectAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
141
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
142 ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
143
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 return None, True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 def deactivate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Public method to deactivate this plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
150 ericApp().getObject("Project").showMenu.disconnect(self.__projectShowMenu)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
151
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
152 menu = ericApp().getObject("Project").getMenu("Apidoc")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if menu:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 menu.removeAction(self.__projectAct)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
155 ericApp().getObject("Project").removeEricActions([self.__projectAct])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.__initialize()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
157
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10061
diff changeset
158 def __projectShowMenu(self, menuName, menu): # noqa: U100
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
160 Private slot called, when the the project menu or a submenu is
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 about to be shown.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
162
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @param menuName name of the menu to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @param menu reference to the menu (QMenu)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
166 if menuName == "Apidoc" and self.__projectAct is not None:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
167 self.__projectAct.setEnabled(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
168 ericApp().getObject("Project").getProjectLanguage()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
169 in ["Python", "Python3", "Ruby", "MicroPython"]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
170 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
171
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 def __doEricapi(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
174 Private slot to perform the eric7_api API generation.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
176 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiConfigDialog import (
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
177 EricapiConfigDialog,
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
178 )
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
179 from eric7.Plugins.DocumentationPlugins.Ericapi.EricapiExecDialog import (
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
180 EricapiExecDialog,
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
181 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
182
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
183 eolTranslation = {
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
184 "\r": "cr",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
185 "\n": "lf",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
186 "\r\n": "crlf",
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
187 }
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
188 project = ericApp().getObject("Project")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
189 parms = project.getData("DOCUMENTATIONPARMS", "ERIC4API")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 dlg = EricapiConfigDialog(project, parms)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7960
diff changeset
191 if dlg.exec() == QDialog.DialogCode.Accepted:
9212
1c5cf2022c7e API Generator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192 args, parms, startDir = dlg.generateParameters()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
193 project.setData("DOCUMENTATIONPARMS", "ERIC4API", parms)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
194
9212
1c5cf2022c7e API Generator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 if not startDir:
1c5cf2022c7e API Generator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 startDir = project.ppath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
197
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
198 # add parameter for the eol setting
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 248
diff changeset
199 if not project.useSystemEol():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
200 args.append("--eol={0}".format(eolTranslation[project.getEolString()]))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
201
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 # now do the call
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
203 self.__execDialog = EricapiExecDialog("Ericapi")
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
204 self.__execDialog.finished.connect(self.__execDialogFinished)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
205 self.__execDialog.processFinished.connect(self.__ericapiProcessFinished)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
206 self.__execDialog.show()
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
207 self.__execDialog.start(args, startDir)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
208
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
209 @pyqtSlot()
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
210 def __ericapiProcessFinished(self):
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
211 """
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
212 Private slot to perform actions after the API data was generated.
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
213 """
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
214 project = ericApp().getObject("Project")
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
215 parms = project.getData("DOCUMENTATIONPARMS", "ERIC4DOC")
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
216
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
217 outputFileName = FileSystemUtilities.toNativeSeparators(parms["outputFile"])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
218
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
219 # add output files to the project data, if they aren't in already
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
220 for progLanguage in parms["languages"]:
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
221 if "%L" in outputFileName:
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
222 outfile = outputFileName.replace("%L", progLanguage)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
223 else:
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
224 if len(parms["languages"]) == 1:
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
225 outfile = outputFileName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 else:
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
227 root, ext = os.path.splitext(outputFileName)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
228 outfile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
229
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
230 outfile = project.getRelativePath(outfile)
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
231 if outfile not in project.getProjectData(dataKey="OTHERS"):
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
232 project.appendFile(outfile)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9212
diff changeset
233
10315
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
234 @pyqtSlot()
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
235 def __execDialogFinished(self):
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
236 """
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
237 Private slot to handle the execution dialog being closed.
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
238 """
4102a69604eb Modified the API and code documentation generator dialogs to allow better error handling (i.e. the dialogs are not modal anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
239 self.__execDialog = None

eric ide

mercurial