Sat, 23 Dec 2023 15:48:12 +0100
Updated copyright for 2024.
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
3 | # Copyright (c) 2017 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing functions to prepare an HTML documentation view. |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
10 | import os |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
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:
8312
diff
changeset
|
12 | from PyQt6.QtCore import QCoreApplication |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
13 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
14 | from eric7 import Utilities |
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.EricWidgets.EricApplication import ericApp |
7523
6e26ec343c78
CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
16 | |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
17 | _stylesheetsCache = { |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
18 | "dark": "", |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
19 | "light": "", |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
20 | } |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
21 | |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
22 | |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
23 | def _stylesheet(): |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
24 | """ |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
25 | Function to get the stylesheet matching the desktop environment. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
26 | |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
27 | @return stylesheet |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
28 | @rtype str |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
29 | """ |
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
|
30 | stylesheetType = "dark" if ericApp().usesDarkPalette() else "light" |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
31 | if not _stylesheetsCache[stylesheetType]: |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
32 | # load the stylesheet from file |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
33 | stylesheetFilePath = os.path.join( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | os.path.dirname(__file__), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | "data", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | "documentViewerStyle-{0}.css".format(stylesheetType), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | ) |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
38 | with open(stylesheetFilePath, "r") as f: |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
39 | _stylesheetsCache[stylesheetType] = f.read() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
41 | return _stylesheetsCache[stylesheetType] |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
42 | |
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
43 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | def prepareDocumentationViewerHtmlDocument(documentationInfo): |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | Public function to prepare the HTML document. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | @param documentationInfo dictionary containing the various documentation |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | parts |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @type dict |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @return prepared HTML document |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @rtype str |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | mainTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | <!DOCTYPE html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | <html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | <head> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
59 | <style>{0}</style> |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | </head> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | <body> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | @HEADER@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @DOCSTRING@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | </body> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | </html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | headerTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | @TITLE@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | @METADATA@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | titleTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | <div class="title"><h1>@NAME@</h1></div> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | metadataTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | <div class="metadata"> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | @ARGSPEC@ |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
80 | @TYPE@ |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | @NOTE@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | </div> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | |
5942
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
85 | argspecTemplate = QCoreApplication.translate( |
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
86 | "CodeDocumentationViewer", |
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
87 | '<p><b>Definition:</b> <span class="def">@NAME@@ARGSPEC@</span></p>', |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
88 | "Just translate 'Definition:' and leave the rest intact.", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
89 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
91 | typeTemplate = QCoreApplication.translate( |
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
92 | "CodeDocumentationViewer", |
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
93 | "<p><b>Type:</b> @TYPE@</p>", |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | "Just translate 'Type:' and leave the rest intact.", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | |
5942
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
97 | noteTemplate = QCoreApplication.translate( |
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
98 | "CodeDocumentationViewer", |
8b083e33c51f
Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5919
diff
changeset
|
99 | "<p><b>Note:</b> @NOTE@</p>", |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
100 | "Just translate 'Note:' and leave the rest intact.", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
101 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
102 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | docstringTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | <div class="docstring"> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | @DOCSTRING@ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | </div> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
108 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | name = documentationInfo["name"] |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | if name: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | title = titleTemplate.replace("@NAME@", name) |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
112 | if "argspec" in documentationInfo and documentationInfo["argspec"]: |
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
113 | argspec = Utilities.html_encode(documentationInfo["argspec"]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
114 | for char in ["=", ",", "(", ")", "*", "**"]: |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
115 | argspec = argspec.replace( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
116 | char, '<span class="argspec-highlight">{0}</span>'.format(char) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
117 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
118 | argspec = argspecTemplate.replace("@NAME@", name).replace( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
119 | "@ARGSPEC@", argspec |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
120 | ) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
122 | argspec = argspecTemplate.replace("@NAME@", name).replace("@ARGSPEC@", "") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
124 | if "typ" in documentationInfo and documentationInfo["typ"]: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
125 | typeInfo = typeTemplate.replace("@TYPE@", documentationInfo["typ"]) |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
126 | else: |
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
127 | typeInfo = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
128 | |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
129 | if "note" in documentationInfo and documentationInfo["note"]: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
130 | note = noteTemplate.replace("@NOTE@", documentationInfo["note"]) |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
131 | else: |
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
132 | note = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
133 | |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
134 | metaData = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | metadataTemplate.replace("@ARGSPEC@", argspec) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
136 | .replace("@TYPE@", typeInfo) |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
137 | .replace("@NOTE@", note) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
138 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | header = headerTemplate.replace("@TITLE@", title).replace( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
141 | "@METADATA@", metaData |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
142 | ) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | else: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | header = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
145 | |
5961
2a5232311a65
Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5960
diff
changeset
|
146 | if "docstring" in documentationInfo and documentationInfo["docstring"]: |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
147 | docstring = ( |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
148 | documentationInfo["docstring"] |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
149 | .replace("\r\n", "<br/>") |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
150 | .replace("\n", "<br/>") |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | .replace("\r", "<br/>") |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
152 | ) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | docstring = docstringTemplate.replace("@DOCSTRING@", docstring) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | docstring = """<div class="hr"></div><div id="doc-warning">{0}</div>""".format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
156 | QCoreApplication.translate( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
157 | "CodeDocumentationViewer", "No further documentation available" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
158 | ) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
159 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
161 | return ( |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
162 | mainTemplate.format(_stylesheet()) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
163 | .replace("@HEADER@", header) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | .replace("@DOCSTRING@", docstring) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
165 | ) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
167 | |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
168 | def prepareDocumentationViewerHtmlDocWarningDocument(text): |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | Public function to prepare a HTML warning document. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
171 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | @param text warning text to be shown |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | @type str |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | @return prepared HTML document |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | @rtype str |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | mainTemplate = """ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | <!DOCTYPE html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | <html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | <head> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
182 | <style>{0}</style> |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | </head> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | <body> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | <div id="doc-warning">@TEXT@</div> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | </body> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | </html> |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
189 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | return mainTemplate.format(_stylesheet()).replace("@TEXT@", text) |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
191 | |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
192 | |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
193 | def prepareDocumentationViewerHtmlWarningDocument(text): |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
194 | """ |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
195 | Public function to prepare a HTML warning document. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
196 | |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
197 | @param text warning text to be shown |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
198 | @type str |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
199 | @return prepared HTML document |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
200 | @rtype str |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
201 | """ |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
202 | mainTemplate = """ |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
203 | <!DOCTYPE html> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
204 | <html> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
205 | <head> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
206 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
7717
f32d7965a17e
Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7716
diff
changeset
|
207 | <style>{0}</style> |
5919
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
208 | </head> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
209 | <body> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
210 | <div id="warning">@TEXT@</div> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
211 | </body> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
212 | </html> |
d0de2b378b24
Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
213 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
214 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
215 | return mainTemplate.format(_stylesheet()).replace("@TEXT@", text) |