eric6/UI/CodeDocumentationViewerTemplate.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7717
f32d7965a17e
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7717
diff changeset
3 # Copyright (c) 2017 - 2021 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
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
12 from PyQt5.QtCore import QCoreApplication
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
7523
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
14 from E5Gui.E5Application import e5App
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
15
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
16 import Utilities
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.
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
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 """
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 stylesheetType = "dark" if e5App().usesDarkPalette() else "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
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(
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
36 os.path.dirname(__file__), "data",
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
37 "documentViewerStyle-{0}.css".format(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
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()
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
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.
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 @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 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
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 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
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 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
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 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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>',
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
88 "Just translate 'Definition:' and leave the rest intact.")
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
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
90 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
91 "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
92 "<p><b>Type:</b> @TYPE@</p>",
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 "Just translate 'Type:' and leave the rest intact.")
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
5942
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
95 noteTemplate = QCoreApplication.translate(
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
96 "CodeDocumentationViewer",
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
97 "<p><b>Note:</b> @NOTE@</p>",
8b083e33c51f Corrected two strings to make them translatable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
98 "Just translate 'Note:' and leave the rest intact.")
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 docstringTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 <div class="docstring">
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 @DOCSTRING@
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 </div>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 name = documentationInfo["name"]
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 if name:
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 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
109 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
110 argspec = Utilities.html_encode(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
111 for char in ['=', ',', '(', ')', '*', '**']:
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 argspec = argspec.replace(
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 char,
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 '<span class="argspec-highlight">{0}</span>'.format(
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 char))
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
116 argspec = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
117 argspecTemplate
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
118 .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
119 .replace("@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:
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 argspec = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
123 argspecTemplate
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
124 .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
125 .replace("@ARGSPEC@", "")
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
126 )
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
127
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 if "typ" in documentationInfo and documentationInfo["typ"]:
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 = typeTemplate.replace("@TYPE@",
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5960
diff changeset
130 documentationInfo["typ"])
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 typeInfo = ""
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
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 if "note" in documentationInfo and documentationInfo["note"]:
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5960
diff changeset
135 note = noteTemplate.replace("@NOTE@",
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5960
diff changeset
136 documentationInfo["note"])
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 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
138 note = ""
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
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
140 metaData = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
141 metadataTemplate
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
142 .replace("@ARGSPEC@", argspec)
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
143 .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
144 .replace("@NOTE@", note)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
145 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
147 header = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
148 headerTemplate
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
149 .replace("@TITLE@", title)
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 .replace("@METADATA@", metaData)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 else:
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 header = ""
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
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
155 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
156 docstring = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
157 documentationInfo["docstring"]
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
158 .replace("\r\n", "<br/>")
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
159 .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
160 .replace("\r", "<br/>")
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
161 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 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
163 else:
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
164 docstring = (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
165 """<div class="hr"></div><div id="doc-warning">{0}</div>"""
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
166 .format(QCoreApplication.translate(
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 "CodeDocumentationViewer",
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 "No further documentation available"))
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
169 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
171 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
172 mainTemplate.format(_stylesheet())
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
173 .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
174 .replace("@DOCSTRING@", docstring)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
175 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
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
177
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5914
diff changeset
178 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
179 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Public function to prepare a HTML warning document.
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @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
183 @type str
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @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
185 @rtype str
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 mainTemplate = """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 <!DOCTYPE html>
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 <head>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 <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
192 <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
193 </head>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 <body>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 <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
196 </body>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 </html>
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
7523
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
200 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
201 mainTemplate.format(_stylesheet())
7523
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
202 .replace("@TEXT@", text)
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
203 )
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
204
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
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 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
207 """
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 Public function to prepare a HTML warning 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
209
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 @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
211 @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
212 @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
213 @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
214 """
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 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
216 <!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
217 <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
218 <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
219 <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
220 <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
221 </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
222 <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
223 <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
224 </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
225 </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
226 """
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5914
diff changeset
227
7523
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
228 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
229 mainTemplate.format(_stylesheet())
7523
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
230 .replace("@TEXT@", text)
6e26ec343c78 CodeDocumentationViewer: added a dark colored style sheet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
231 )

eric ide

mercurial