Sat, 21 Oct 2017 14:43:51 +0200
Fixed a few issues.
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de> |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a widget to show some source code information provided by |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | plug-ins. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from __future__ import unicode_literals |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
13 | from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QThread, QUrl |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
14 | from PyQt5.QtGui import QCursor |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
15 | from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, \ |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
16 | QComboBox, QSizePolicy, QLineEdit, QTextEdit, QToolTip, QToolButton, \ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
17 | QActionGroup, QMenu |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
19 | from E5Gui.E5TextEditSearchWidget import E5TextEditSearchWidget |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
20 | from E5Gui.E5ToolButton import E5ToolButton |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | import Preferences |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
23 | import UI.PixmapCache |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
25 | from .CodeDocumentationViewerTemplate import \ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
26 | prepareDocumentationViewerHtmlDocument, \ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
27 | prepareDocumentationViewerHtmlWarningDocument |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
28 | |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
29 | from .data import codeDocumentationViewer_rc # __IGNORE_WARNING__ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
30 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
32 | class PlainTextDocumentationViewer(QWidget): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
33 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
34 | Class implementing the plain text documentation viewer. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
35 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
36 | def __init__(self, parent=None): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
37 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
38 | Constructor |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
39 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
40 | @param parent reference to the parent widget |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
41 | @type QWidget |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
42 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
43 | super(PlainTextDocumentationViewer, self).__init__(parent) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
44 | self.setObjectName("PlainTextDocumentationViewer") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
45 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
46 | self.__verticalLayout = QVBoxLayout(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
47 | self.__verticalLayout.setObjectName("verticalLayout") |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
48 | self.__verticalLayout.setContentsMargins(0, 0, 0, 0) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
49 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
50 | self.__contents = QTextEdit(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
51 | self.__contents.setTabChangesFocus(True) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
52 | self.__contents.setReadOnly(True) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
53 | self.__contents.setLineWrapMode(QTextEdit.NoWrap) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
54 | self.__contents.setObjectName("contents") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
55 | self.__verticalLayout.addWidget(self.__contents) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
56 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
57 | self.__searchWidget = E5TextEditSearchWidget(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
58 | self.__searchWidget.setFocusPolicy(Qt.WheelFocus) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
59 | self.__searchWidget.setObjectName("searchWidget") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
60 | self.__verticalLayout.addWidget(self.__searchWidget) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
61 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
62 | self.__searchWidget.attachTextEdit(self.__contents, "QTextEdit") |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
63 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
64 | self.preferencesChanged() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
65 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
66 | def clear(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
67 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
68 | Public method to clear the contents. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
69 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
70 | self.__contents.clear() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
71 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
72 | def setText(self, text): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
73 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
74 | Public method to set the text to be shown. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
75 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
76 | @param text text to be shown |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
77 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
78 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
79 | self.__contents.setPlainText(text) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
80 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
81 | def preferencesChanged(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
82 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
83 | Public slot to handle a change of preferences. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
84 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
85 | font = Preferences.getEditorOtherFonts("MonospacedFont") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
86 | self.__contents.setFontFamily(font.family()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
87 | self.__contents.setFontPointSize(font.pointSize()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
88 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
89 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
90 | class WebViewDocumentationViewer(QWidget): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
91 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
92 | Class implementing the rich text documentation viewer. |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
93 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
94 | def __init__(self, parent=None): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
95 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
96 | Constructor |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
97 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
98 | @param parent reference to the parent widget |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
99 | @type QWidget |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
100 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
101 | super(WebViewDocumentationViewer, self).__init__(parent) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
102 | self.setObjectName("WebViewDocumentationViewer") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
103 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
104 | self.__verticalLayout = QVBoxLayout(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
105 | self.__verticalLayout.setObjectName("verticalLayout") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
106 | self.__verticalLayout.setContentsMargins(0, 0, 0, 0) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
107 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
108 | try: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
109 | from PyQt5.QtWebEngineWidgets import QWebEngineView, \ |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
110 | QWebEngineSettings |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
111 | self.__contents = QWebEngineView(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
112 | self.__contents.page().linkHovered.connect(self.__showLink) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
113 | try: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
114 | self.__contents.settings().setAttribute( |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
115 | QWebEngineSettings.FocusOnNavigationEnabled, False) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
116 | except AttributeError: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
117 | # pre Qt 5.8 |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
118 | pass |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
119 | self.__usesWebKit = False |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
120 | except ImportError: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
121 | from PyQt5.QtWebKitWidgets import QWebPage, QWebView |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
122 | self.__contents = QWebView(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
123 | self.__contents.page().setLinkDelegationPolicy( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
124 | QWebPage.DelegateAllLinks) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
125 | self.__usesWebKit = True |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
126 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
127 | sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
128 | sizePolicy.setHorizontalStretch(0) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
129 | sizePolicy.setVerticalStretch(0) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
130 | sizePolicy.setHeightForWidth( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
131 | self.__contents.sizePolicy().hasHeightForWidth()) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
132 | self.__contents.setSizePolicy(sizePolicy) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
133 | self.__contents.setContextMenuPolicy(Qt.NoContextMenu) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
134 | self.__contents.setUrl(QUrl("about:blank")) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
135 | self.__verticalLayout.addWidget(self.__contents) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
136 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
137 | self.__searchWidget = E5TextEditSearchWidget(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
138 | self.__searchWidget.setFocusPolicy(Qt.WheelFocus) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
139 | self.__searchWidget.setObjectName("searchWidget") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
140 | self.__verticalLayout.addWidget(self.__searchWidget) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
141 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
142 | self.__searchWidget.attachTextEdit( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
143 | self.__contents, |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
144 | "QWebView" if self.__usesWebKit else "QWebEngineView", |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
145 | ) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
146 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
147 | @pyqtSlot(str) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
148 | def __showLink(self, urlStr): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
149 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
150 | Private slot to show the hovered link in a tooltip. |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
151 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
152 | @param urlStr hovered URL |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
153 | @type str |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
154 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
155 | QToolTip.showText(QCursor.pos(), urlStr, self.__contents) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
156 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
157 | def setHtml(self, html): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
158 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
159 | Public method to set the HTML text of the widget. |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
160 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
161 | @param html HTML text to be shown |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
162 | @type str |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
163 | """ |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
164 | self.__contents.setEnabled(False) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
165 | self.__contents.setHtml(html) |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
166 | self.__contents.setEnabled(True) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
167 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
168 | def clear(self): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
169 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
170 | Public method to clear the shown contents. |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
171 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
172 | self.__contents.setHtml("") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
173 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
174 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
175 | class CodeDocumentationViewer(QWidget): |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | Class implementing a widget to show some source code information provided |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | by plug-ins. |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
179 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
180 | @signal providerAdded() emitted to indicate the availability of a new |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
181 | provider |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
182 | @signal providerRemoved() emitted to indicate the removal of a provider |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | providerAdded = pyqtSignal() |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
185 | providerRemoved = pyqtSignal() |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | def __init__(self, parent=None): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | Constructor |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | @param parent reference to the parent widget |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | @type QWidget |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | super(CodeDocumentationViewer, self).__init__(parent) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
195 | self.__setupUi() |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
196 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | self.__ui = parent |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | self.__providers = {} |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | self.__selectedProvider = "" |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | self.__disabledProvider = "disabled" |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | self.__shuttingDown = False |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.__startingUp = True |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
206 | self.__lastDocumentation = None |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
207 | self.__requestingEditor = None |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
208 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | self.__noDocumentationString = self.tr("No documentation available") |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | self.__disabledString = self.tr( |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | "No source code documentation provider has been registered or" |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | " this function has been disabled.") |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
214 | self.__processingThread = DocumentProcessingThread() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
215 | self.__processingThread.htmlReady.connect(self.__setHtml) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
216 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
217 | def __setupUi(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
218 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
219 | Private method to generate the UI layout. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
220 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
221 | self.setObjectName("CodeDocumentationViewer") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
222 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
223 | self.verticalLayout = QVBoxLayout(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
224 | self.verticalLayout.setObjectName("verticalLayout") |
5915
4bdac859df60
Fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5914
diff
changeset
|
225 | self.verticalLayout.setContentsMargins(3, 3, 3, 3) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
226 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
227 | # top row of widgets |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
228 | self.horizontalLayout = QHBoxLayout() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
229 | self.horizontalLayout.setObjectName("horizontalLayout") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
230 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
231 | self.label = QLabel(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
232 | self.label.setObjectName("label") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
233 | self.label.setText(self.tr("Code Info Provider:")) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
234 | self.horizontalLayout.addWidget(self.label) |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
235 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
236 | self.providerComboBox = QComboBox(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
237 | sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
238 | sizePolicy.setHorizontalStretch(0) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
239 | sizePolicy.setVerticalStretch(0) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
240 | sizePolicy.setHeightForWidth( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
241 | self.providerComboBox.sizePolicy().hasHeightForWidth()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
242 | self.providerComboBox.setSizePolicy(sizePolicy) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
243 | self.providerComboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
244 | self.providerComboBox.setObjectName("providerComboBox") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
245 | self.providerComboBox.setToolTip( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
246 | self.tr("Select the code info provider")) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
247 | self.providerComboBox.addItem(self.tr("<disabled>"), "disabled") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
248 | self.horizontalLayout.addWidget(self.providerComboBox) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
249 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
250 | self.objectLineEdit = QLineEdit(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
251 | self.objectLineEdit.setReadOnly(True) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
252 | self.objectLineEdit.setObjectName("objectLineEdit") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
253 | self.horizontalLayout.addWidget(self.objectLineEdit) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
254 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
255 | self.__toolButton = E5ToolButton(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
256 | self.__toolButton.setObjectName( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
257 | "navigation_supermenu_button") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
258 | self.__toolButton.setIcon(UI.PixmapCache.getIcon("superMenu.png")) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
259 | self.__toolButton.setToolTip(self.tr("Main Menu")) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
260 | self.__toolButton.setPopupMode(QToolButton.InstantPopup) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
261 | self.__toolButton.setToolButtonStyle(Qt.ToolButtonIconOnly) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
262 | self.__toolButton.setFocusPolicy(Qt.NoFocus) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
263 | self.__toolButton.setAutoRaise(True) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
264 | self.__toolButton.setShowMenuInside(True) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
265 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
266 | self.__optionsMenu = QMenu(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
267 | self.__richTextAct = self.__optionsMenu.addAction( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
268 | self.tr("Rich Text"), |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
269 | lambda: self.__showTextViewer(True)) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
270 | self.__richTextAct.setCheckable(True) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
271 | self.__plainTextAct = self.__optionsMenu.addAction( |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
272 | self.tr("Plain Text"), |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
273 | lambda: self.__showTextViewer(False)) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
274 | self.__plainTextAct.setCheckable(True) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
275 | self.__optionsActionGroup = QActionGroup(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
276 | self.__optionsActionGroup.setExclusive(True) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
277 | self.__optionsActionGroup.addAction(self.__richTextAct) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
278 | self.__optionsActionGroup.addAction(self.__plainTextAct) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
279 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
280 | self.__toolButton.setMenu(self.__optionsMenu) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
281 | self.horizontalLayout.addWidget(self.__toolButton) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
282 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
283 | self.verticalLayout.addLayout(self.horizontalLayout) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
284 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
285 | # Plain Text Viewer |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
286 | self.__plainTextViewer = PlainTextDocumentationViewer(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
287 | self.__plainTextViewer.setObjectName("__plainTextViewer") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
288 | self.verticalLayout.addWidget(self.__plainTextViewer) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
289 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
290 | # Rich Text (Web) Viewer |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
291 | self.__richTextViewer = WebViewDocumentationViewer(self) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
292 | self.__richTextViewer.setObjectName("__richTextViewer") |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
293 | self.verticalLayout.addWidget(self.__richTextViewer) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
294 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
295 | self.providerComboBox.currentIndexChanged[int].connect( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
296 | self.on_providerComboBox_currentIndexChanged) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | def finalizeSetup(self): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | Public method to finalize the setup of the documentation viewer. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | """ |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
302 | self.__showTextViewer(Preferences.getDocuViewer("ShowInfoAsMarkdown")) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
303 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | self.__startingUp = False |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
305 | provider = Preferences.getDocuViewer("Provider") |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | if provider in self.__providers: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | index = self.providerComboBox.findData(provider) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | else: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | index = 0 |
5908
4d08fb83a844
Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5905
diff
changeset
|
310 | provider = self.__disabledProvider |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | self.providerComboBox.setCurrentIndex(index) |
5908
4d08fb83a844
Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5905
diff
changeset
|
312 | self.__selectedProvider = provider |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
314 | # TODO: document this hook in the plug-in document |
5911
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
315 | def registerProvider(self, providerName, providerDisplay, provider, |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
316 | supported): |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | Public method register a source docu provider. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | @param providerName name of the provider (must be unique) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | @type str |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | @param providerDisplay visible name of the provider |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | @type str |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | @param provider function to be called to determine source docu |
5911
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
325 | @type function(editor) |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
326 | @param supported function to be called to determine, if a language is |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
327 | supported |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
328 | @type function(language) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | @exception KeyError raised if a provider with the given name was |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | already registered |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | if providerName in self.__providers: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | raise KeyError( |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | "Provider '{0}' already registered.".format(providerName)) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | |
5911
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
336 | self.__providers[providerName] = (provider, supported) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | self.providerComboBox.addItem(providerDisplay, providerName) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
338 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
339 | self.providerAdded.emit() |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
341 | # TODO: document this hook in the plug-in document |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | def unregisterProvider(self, providerName): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | Public method register a source docu provider. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | @param providerName name of the provider (must be unique) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | @type str |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | if providerName in self.__providers: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | if providerName == self.__selectedProvider: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | self.providerComboBox.setCurrentIndex(0) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | del self.__providers[providerName] |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | index = self.providerComboBox.findData(providerName) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | self.providerComboBox.removeItem(index) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
356 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
357 | self.providerRemoved.emit() |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | |
5911
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
359 | def isSupportedLanguage(self, language): |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
360 | """ |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
361 | Public method to check, if the given language is supported by the |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
362 | selected provider. |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
363 | |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
364 | @param language editor programming language to check |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
365 | @type str |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
366 | @return flag indicating the support status |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
367 | @rtype bool |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
368 | """ |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
369 | supported = False |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
370 | |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
371 | if self.__selectedProvider != self.__disabledProvider: |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
372 | supported = self.__providers[self.__selectedProvider][1](language) |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
373 | |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
374 | return supported |
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
375 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
376 | def getProviders(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
377 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
378 | Public method to get a list of providers and their visible strings. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
379 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
380 | @return list containing the providers and their visible strings |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
381 | @rtype list of tuple of (str,str) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
382 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
383 | providers = [] |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
384 | for index in range(1, self.providerComboBox.count()): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
385 | provider = self.providerComboBox.itemData(index) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
386 | text = self.providerComboBox.itemText(index) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
387 | providers.append((provider, text)) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
388 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
389 | return providers |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
390 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | def showInfo(self, editor): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | Public method to request code documentation data from a provider. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | @param editor reference to the editor to request code docu for |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | @type Editor |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | """ |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
398 | line, index = editor.getCursorPosition() |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
399 | word = editor.getWord(line, index) |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
400 | if not word: |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
401 | # try again one index before |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
402 | word = editor.getWord(line, index - 1) |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
403 | self.objectLineEdit.setText(word) |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
404 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
405 | if self.__selectedProvider != self.__disabledProvider: |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
406 | self.__plainTextViewer.clear() |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
407 | self.__richTextViewer.clear() |
5911
0c7bcba51391
Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5908
diff
changeset
|
408 | self.__providers[self.__selectedProvider][0](editor) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
409 | |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
410 | # TODO: document this hook in the plug-in document |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
411 | def documentationReady(self, documentationInfo, isWarning=False): |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
412 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | Public method to provide the documentation info to the viewer. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | If documentationInfo is a dictionary, it should contains these keys |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
416 | and data: |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | name: the name of the inspected object |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
419 | argspec: its argspec |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | note: A phrase describing the type of object (function or method) and |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | the module it belongs to. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | docstring: its documentation string |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
423 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
424 | @param documentationInfo dictionary containing the source docu data |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
425 | @type dict or str |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
426 | @param isWarning flag indicating a warning page |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
427 | @type bool |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
428 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
429 | self.__ui.activateCodeDocumentationViewer(switchFocus=False) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
431 | self.__lastDocumentation = documentationInfo |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
432 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
433 | if documentationInfo is not None: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
434 | if not documentationInfo: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
435 | if self.__selectedProvider == self.__disabledProvider: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
436 | self.documentationReady(self.__disabledString, |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
437 | isWarning=True) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
438 | else: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
439 | self.documentationReady(self.__noDocumentationString, |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
440 | isWarning=True) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
441 | return |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
442 | |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
443 | if self.__showMarkdown: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
444 | if isWarning: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
445 | html = prepareDocumentationViewerHtmlWarningDocument( |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
446 | documentationInfo) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
447 | elif isinstance(documentationInfo, dict): |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
448 | html = prepareDocumentationViewerHtmlDocument( |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
449 | documentationInfo) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
450 | else: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
451 | html = "" |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
452 | if html: |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
453 | self.__setHtml(html) |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
454 | return |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
455 | |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
456 | if isinstance(documentationInfo, str): |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
457 | fullText = documentationInfo |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
458 | elif isinstance(documentationInfo, dict): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
459 | name = documentationInfo["name"] |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
460 | if name: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
461 | title = "".join([name, "\n", |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
462 | "=" * len(name), "\n\n"]) |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
463 | else: |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
464 | title = "" |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
465 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
466 | if documentationInfo["argspec"]: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
467 | definition = self.tr("Definition: {0}{1}\n").format( |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
468 | name, documentationInfo["argspec"]) |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
469 | else: |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
470 | definition = '' |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
471 | |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
472 | if documentationInfo["note"]: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
473 | note = self.tr("Info: {0}\n\n----\n\n").format( |
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
474 | documentationInfo["note"]) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
475 | else: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
476 | note = "" |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
477 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
478 | if documentationInfo["docstring"] is None: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
479 | docString = "" |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
480 | else: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
481 | docString = documentationInfo["docstring"] |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
482 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
483 | fullText = "".join([title, definition, note, docString]) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
484 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
485 | if self.__showMarkdown: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
486 | self.__processingThread.process("markdown", fullText) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
487 | else: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
488 | self.__plainTextViewer.setText(fullText) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
489 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
490 | def __setHtml(self, html): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
491 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
492 | Private slot to set the prepared HTML text. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
493 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
494 | @param html prepared HTML text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
495 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
496 | """ |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
497 | self.__richTextViewer.setHtml(html) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
498 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
499 | @pyqtSlot(int) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
500 | def on_providerComboBox_currentIndexChanged(self, index): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
501 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | Private slot to handle the selection of a provider. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | @param index index of the selected provider |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | @type int |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
506 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
507 | if not self.__shuttingDown and not self.__startingUp: |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
508 | self.__plainTextViewer.clear() |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
509 | self.__richTextViewer.clear() |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
510 | self.objectLineEdit.clear() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
511 | |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
512 | provider = self.providerComboBox.itemData(index) |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | if provider == self.__disabledProvider: |
5914
e44c04a89dbc
Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5913
diff
changeset
|
514 | self.documentationReady(self.__disabledString, isWarning=True) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
515 | else: |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
516 | self.__lastDocumentation = None |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
517 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
518 | Preferences.setDocuViewer("Provider", provider) |
5900
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | self.__selectedProvider = provider |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
521 | def shutdown(self): |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
522 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
523 | Public method to perform shutdown actions. |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
524 | """ |
cd90bfdc1247
Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
525 | self.__shuttingDown = True |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
526 | Preferences.setDocuViewer("Provider", self.__selectedProvider) |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
527 | |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
528 | def preferencesChanged(self): |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
529 | """ |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
530 | Public slot to handle a change of preferences. |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
531 | """ |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
532 | showMarkdown = Preferences.getDocuViewer("ShowInfoAsMarkdown") |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
533 | if showMarkdown != self.__showMarkdown: |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
534 | self.__showTextViewer(showMarkdown) |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
535 | |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
536 | provider = Preferences.getDocuViewer("Provider") |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
537 | if provider != self.__selectedProvider: |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
538 | index = self.providerComboBox.findData(provider) |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
539 | if index < 0: |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
540 | index = 0 |
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
541 | self.providerComboBox.setCurrentIndex(index) |
5913
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
542 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
543 | def __showTextViewer(self, richText): |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
544 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
545 | Private slot to show the selected viewer. |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
546 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
547 | @param richText flag indicating the rich text viewer |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
548 | @type bool |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
549 | """ |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
550 | self.__showMarkdown = richText |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
551 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
552 | self.__plainTextViewer.clear() |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
553 | self.__richTextViewer.clear() |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
554 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
555 | self.__plainTextViewer.setVisible(not richText) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
556 | self.__richTextViewer.setVisible(richText) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
557 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
558 | self.__plainTextAct.setChecked(not richText) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
559 | self.__richTextAct.setChecked(richText) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
560 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
561 | self.documentationReady(self.__lastDocumentation) |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
562 | |
7ab2293917f8
Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5912
diff
changeset
|
563 | Preferences.setDocuViewer("ShowInfoAsMarkdown", richText) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
564 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
565 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
566 | class DocumentProcessingThread(QThread): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
567 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
568 | Class implementing a thread to process some text into HTML usable by the |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
569 | viewer. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
570 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
571 | @signal htmlReady(str) emitted with the processed HTML to signal the |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
572 | availability of the processed HTML |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
573 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
574 | htmlReady = pyqtSignal(str) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
575 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
576 | def __init__(self, parent=None): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
577 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
578 | Constructor |
5905
f31960634997
Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5900
diff
changeset
|
579 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
580 | @param parent reference to the parent object (QObject) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
581 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
582 | super(DocumentProcessingThread, self).__init__() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
583 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
584 | def process(self, language, text): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
585 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
586 | Public method to convert the given text to HTML. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
587 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
588 | @param language language of the text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
589 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
590 | @param text text to be processed |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
591 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
592 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
593 | if self.wait(): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
594 | self.__language = language |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
595 | self.__text = text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
596 | self.start() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
597 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
598 | def run(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
599 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
600 | Public thread method to convert the stored data. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
601 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
602 | language = self.__language |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
603 | text = self.__text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
604 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
605 | if language == "markdown": |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
606 | html = self.__convertMarkdown(text, True, "html5") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
607 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
608 | html = "<html><body><p>" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
609 | html += self.tr("Format '{0}' is not supported.").format(language) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
610 | html += "</p></body></html>" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
611 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
612 | self.htmlReady.emit(html) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
613 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
614 | def __convertMarkdown(self, text, convertNewLineToBreak, htmlFormat): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
615 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
616 | Private method to convert Markdown text into HTML. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
617 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
618 | @param text text to be processed |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
619 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
620 | @param convertNewLineToBreak flag indicating to convert new lines |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
621 | to HTML break |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
622 | @type bool |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
623 | @param htmlFormat HTML format to be generated by markdown |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
624 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
625 | @return processed HTML |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
626 | @rtype str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
627 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
628 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
629 | import markdown # __IGNORE_EXCEPTION__ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
630 | except ImportError: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
631 | return self.tr( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
632 | """<p>Markdown view requires the <b>Markdown</b> """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
633 | """package.<br/>Install it with your package manager,""" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
634 | """ 'pip install Markdown' or see """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
635 | """<a href="http://pythonhosted.org/Markdown/install.html">""" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
636 | """installation instructions.</a></p>""") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
637 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
638 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
639 | import mdx_mathjax # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
640 | except ImportError: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
641 | # mathjax doesn't require import statement if installed |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
642 | # as extension |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
643 | pass |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
644 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
645 | if convertNewLineToBreak: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
646 | extensions = ['fenced_code', 'nl2br', 'extra'] |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
647 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
648 | extensions = ['fenced_code', 'extra'] |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
649 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
650 | # version 2.0 supports only extension names, not instances |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
651 | if markdown.version_info[0] > 2 or \ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
652 | (markdown.version_info[0] == 2 and |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
653 | markdown.version_info[1] > 0): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
654 | class _StrikeThroughExtension(markdown.Extension): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
655 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
656 | Class is placed here, because it depends on imported markdown, |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
657 | and markdown import is lazy. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
658 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
659 | (see https://pythonhosted.org/Markdown/extensions/api.html |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
660 | this page for details) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
661 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
662 | DEL_RE = r'(~~)(.*?)~~' |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
663 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
664 | def extendMarkdown(self, md, md_globals): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
665 | # Create the del pattern |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
666 | del_tag = markdown.inlinepatterns.SimpleTagPattern( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
667 | self.DEL_RE, 'del') |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
668 | # Insert del pattern into markdown parser |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
669 | md.inlinePatterns.add('del', del_tag, '>not_strong') |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
670 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
671 | extensions.append(_StrikeThroughExtension()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
672 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
673 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
674 | return markdown.markdown(text, extensions=extensions + ['mathjax'], |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
675 | output_format=htmlFormat.lower()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
676 | except (ImportError, ValueError): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
677 | # markdown raises ValueError or ImportError, depends on version |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
678 | # It is not clear, how to distinguish missing mathjax from other |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
679 | # errors. So keep going without mathjax. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
680 | return markdown.markdown(text, extensions=extensions, |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
681 | output_format=htmlFormat.lower()) |