src/eric7/UI/CodeDocumentationViewerTemplate.py

Tue, 18 Oct 2022 16:06:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Oct 2022 16:06:21 +0200
branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
permissions
-rw-r--r--

Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.

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
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
3 # Copyright (c) 2017 - 2022 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
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
14 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
15
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
16 from eric7 import Utilities
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
17
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5914
diff changeset
18
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
19 _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
20 "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
21 "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
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
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 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
26 """
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 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
28
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
29 @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
30 @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
31 """
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
32 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
33 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
34 # 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
35 stylesheetFilePath = os.path.join(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
36 os.path.dirname(__file__),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
37 "data",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
38 "documentViewerStyle-{0}.css".format(stylesheetType),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
39 )
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
40 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
41 _stylesheetsCache[stylesheetType] = f.read()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
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
43 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
44
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
45
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 def prepareDocumentationViewerHtmlDocument(documentationInfo):
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 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
49
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @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
51 parts
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @type dict
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @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
54 @rtype str
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 mainTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 <!DOCTYPE html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 <html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 <head>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 <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
61 <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
62 </head>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 <body>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @HEADER@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @DOCSTRING@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 </body>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 </html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
69
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 headerTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 @TITLE@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @METADATA@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 titleTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 <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
77 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 metadataTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 <div class="metadata">
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @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
82 @TYPE@
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @NOTE@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 </div>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
86
5942
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
87 argspecTemplate = QCoreApplication.translate(
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
88 "CodeDocumentationViewer",
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
89 '<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
90 "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
91 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
92
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
93 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
94 "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
95 "<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
96 "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
97 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98
5942
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
99 noteTemplate = QCoreApplication.translate(
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
100 "CodeDocumentationViewer",
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
101 "<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
102 "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
103 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 docstringTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 <div class="docstring">
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 @DOCSTRING@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 </div>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 name = documentationInfo["name"]
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 if name:
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 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
114 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
115 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
116 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
117 argspec = argspec.replace(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 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
119 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
120 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
121 "@ARGSPEC@", argspec
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124 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
125
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 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
127 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
128 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
129 typeInfo = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
130
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 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
132 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
133 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
134 note = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
135
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
136 metaData = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 metadataTemplate.replace("@ARGSPEC@", argspec)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
138 .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
139 .replace("@NOTE@", note)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
140 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
142 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
143 "@METADATA@", metaData
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
144 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 else:
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 header = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
147
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
148 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
149 docstring = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
150 documentationInfo["docstring"]
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 .replace("\r\n", "<br/>")
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
152 .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
153 .replace("\r", "<br/>")
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
154 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 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
156 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
157 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
158 QCoreApplication.translate(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
159 "CodeDocumentationViewer", "No further documentation available"
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 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
163 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
164 mainTemplate.format(_stylesheet())
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
165 .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
166 .replace("@DOCSTRING@", docstring)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
167 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
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
169
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5914
diff changeset
170 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
171 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 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
173
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @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
175 @type str
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @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
177 @rtype str
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 mainTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 <!DOCTYPE html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 <html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 <head>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 <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
184 <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
185 </head>
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 <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
188 </body>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 </html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
191
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192 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
193
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 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
196 """
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 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
198
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
199 @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
200 @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
201 @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
202 @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
203 """
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 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
205 <!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
206 <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
207 <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
208 <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
209 <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
210 </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
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 <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
213 </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
214 </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
215 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
217 return mainTemplate.format(_stylesheet()).replace("@TEXT@", text)

eric ide

mercurial