Tue, 17 Oct 2017 19:40:32 +0200
Added the rich text view to the documentation viewer.
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 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
13 | from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QThread |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
14 | from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, \ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
15 | QComboBox, QSizePolicy, QLineEdit, QTextEdit |
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
|
16 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
17 | from E5Gui.E5TextEditSearchWidget import E5TextEditSearchWidget |
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 | |
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
|
19 | import Preferences |
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
|
20 | |
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 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
22 | class PlainTextDocumentationViewer(QWidget): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
23 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
24 | 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
|
25 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
26 | 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
|
27 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
28 | Constructor |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
29 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
30 | @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
|
31 | @type QWidget |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
32 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
33 | 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
|
34 | self.setObjectName("PlainTextDocumentationViewer") |
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 | self.__verticalLayout = QVBoxLayout(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
37 | self.__verticalLayout.setObjectName("verticalLayout") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
38 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
39 | self.__contents = QTextEdit(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
40 | self.__contents.setTabChangesFocus(True) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
41 | self.__contents.setReadOnly(True) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
42 | self.__contents.setObjectName("contents") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
43 | 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
|
44 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
45 | self.__searchWidget = E5TextEditSearchWidget(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
46 | 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
|
47 | self.__searchWidget.setObjectName("searchWidget") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
48 | 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
|
49 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
50 | self.__searchWidget.attachTextEdit(self.__contents) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
51 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
52 | self.preferencesChanged() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
53 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
54 | def clear(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
55 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
56 | 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
|
57 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
58 | self.__contents.clear() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
59 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
60 | def setText(self, text): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
61 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
62 | 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
|
63 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
64 | @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
|
65 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
66 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
67 | self.__contents.setPlainText(text) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
68 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
69 | def setHtml(self, html): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
70 | self.__contents.setHtml(html) |
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 preferencesChanged(self): |
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 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
|
75 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
76 | font = Preferences.getEditorOtherFonts("MonospacedFont") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
77 | 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
|
78 | 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
|
79 | |
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 | 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
|
82 | """ |
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
|
83 | 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
|
84 | by 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
|
85 | """ |
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
|
86 | providerAdded = pyqtSignal() |
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
|
87 | |
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
|
88 | 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
|
89 | """ |
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
|
90 | 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
|
91 | |
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
|
92 | @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
|
93 | @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
|
94 | """ |
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
|
95 | 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
|
96 | 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
|
97 | |
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
|
98 | 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
|
99 | |
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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | |
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
|
104 | 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
|
105 | 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
|
106 | |
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
|
107 | self.__lastDocumentation = None |
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
|
108 | |
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
|
109 | self.__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
|
110 | |
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
|
111 | 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
|
112 | 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
|
113 | "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
|
114 | " 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
|
115 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
116 | self.__processingThread = DocumentProcessingThread() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
117 | 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
|
118 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
119 | def __setupUi(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
120 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
121 | 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
|
122 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
123 | self.setObjectName("CodeDocumentationViewer") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
124 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
125 | self.verticalLayout = QVBoxLayout(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
126 | self.verticalLayout.setObjectName("verticalLayout") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
127 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
128 | # top row of widgets |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
129 | self.horizontalLayout = QHBoxLayout() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
130 | self.horizontalLayout.setObjectName("horizontalLayout") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
131 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
132 | self.label = QLabel(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
133 | self.label.setObjectName("label") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
134 | 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
|
135 | 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
|
136 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
137 | self.providerComboBox = QComboBox(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
138 | 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
|
139 | sizePolicy.setHorizontalStretch(0) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
140 | sizePolicy.setVerticalStretch(0) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
141 | sizePolicy.setHeightForWidth( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
142 | self.providerComboBox.sizePolicy().hasHeightForWidth()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
143 | self.providerComboBox.setSizePolicy(sizePolicy) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
144 | 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
|
145 | self.providerComboBox.setObjectName("providerComboBox") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
146 | self.providerComboBox.setToolTip( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
151 | self.objectLineEdit = QLineEdit(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
152 | self.objectLineEdit.setReadOnly(True) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
153 | self.objectLineEdit.setObjectName("objectLineEdit") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
154 | 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
|
155 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
156 | 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
|
157 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
158 | self.contents = PlainTextDocumentationViewer(self) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
159 | self.contents.setObjectName("contents") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
160 | 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
|
161 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
162 | 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
|
163 | 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
|
164 | |
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
|
165 | 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
|
166 | """ |
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
|
167 | 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
|
168 | """ |
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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | index = 0 |
5908
4d08fb83a844
Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5905
diff
changeset
|
175 | 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
|
176 | self.providerComboBox.setCurrentIndex(index) |
5908
4d08fb83a844
Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5905
diff
changeset
|
177 | 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
|
178 | |
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
|
179 | # 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
|
180 | 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
|
181 | 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
|
182 | """ |
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 | 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
|
184 | |
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
|
185 | @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
|
186 | @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
|
187 | @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
|
188 | @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
|
189 | @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
|
190 | @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
|
191 | @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
|
192 | 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
|
193 | @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
|
194 | @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
|
195 | 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
|
196 | """ |
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 | 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
|
198 | 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
|
199 | "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
|
200 | |
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
|
201 | 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
|
202 | self.providerComboBox.addItem(providerDisplay, 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
|
203 | |
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
|
204 | # 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
|
205 | 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
|
206 | """ |
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
|
207 | 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
|
208 | |
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 | @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
|
210 | @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
|
211 | """ |
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 | 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
|
213 | 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
|
214 | 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
|
215 | |
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
|
216 | 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
|
217 | 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
|
218 | self.providerComboBox.removeItem(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
|
219 | |
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
|
220 | 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
|
221 | """ |
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
|
222 | 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
|
223 | 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
|
224 | |
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
|
225 | @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
|
226 | @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
|
227 | @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
|
228 | @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
|
229 | """ |
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
|
230 | 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
|
231 | |
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
|
232 | 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
|
233 | 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
|
234 | |
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
|
235 | 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
|
236 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
237 | def getProviders(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
238 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
239 | 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
|
240 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
241 | @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
|
242 | @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
|
243 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
244 | providers = [] |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | providers.append((provider, text)) |
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 | return providers |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
251 | |
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
|
252 | 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
|
253 | """ |
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
|
254 | 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
|
255 | |
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
|
256 | @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
|
257 | @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
|
258 | """ |
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
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | # try again one index before |
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
|
263 | word = editor.getWord(line, index - 1) |
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
|
264 | 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
|
265 | |
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
|
266 | if self.__selectedProvider != self.__disabledProvider: |
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
|
267 | self.contents.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
|
268 | 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
|
269 | |
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
|
270 | # 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
|
271 | def documentationReady(self, documentationInfo): |
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
|
272 | """ |
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
|
273 | 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
|
274 | |
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
|
275 | 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
|
276 | 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
|
277 | |
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
|
278 | 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
|
279 | 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
|
280 | 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
|
281 | 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
|
282 | 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
|
283 | |
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
|
284 | @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
|
285 | @type dict or 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
|
286 | """ |
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
|
287 | 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
|
288 | |
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
|
289 | 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
|
290 | |
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
|
291 | if not documentationInfo: |
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
|
292 | fullText = self.__noDocumentationString |
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
|
293 | elif isinstance(documentationInfo, 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
|
294 | fullText = documentationInfo |
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
|
295 | elif isinstance(documentationInfo, dict): |
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
|
296 | # format the text with markdown syntax |
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 | name = documentationInfo["name"] |
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 | if name: |
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
|
299 | title = "".join([name, "\n", |
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
|
300 | "=" * len(name), "\n\n"]) |
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 | 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
|
302 | title = "" |
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
|
303 | |
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 | if 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
|
305 | if self.__showMarkdown: |
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
|
306 | definition = self.tr("**Definition**: {0}{1}\n", |
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
|
307 | "string with markdown syntax").format( |
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
|
308 | name, documentationInfo["argspec"]) |
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
|
309 | else: |
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
|
310 | definition = self.tr("Definition: {0}{1}\n", |
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
|
311 | "string as plain text").format( |
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
|
312 | name, documentationInfo["argspec"]) |
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 | 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
|
314 | definition = '' |
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
|
315 | |
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
|
316 | if documentationInfo["note"]: |
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
|
317 | if self.__showMarkdown: |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
318 | note = self.tr("**Info**: {0}\n\n----\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
|
319 | "string with markdown syntax").format( |
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
|
320 | documentationInfo["note"]) |
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
|
321 | else: |
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
|
322 | note = self.tr("Info: {0}\n\n----\n\n", |
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
|
323 | "string as plain text").format( |
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
|
324 | documentationInfo["note"]) |
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
|
325 | 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
|
326 | note = "" |
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
|
327 | |
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
|
328 | fullText = "".join([title, definition, note, |
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 | documentationInfo['docstring']]) |
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 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
331 | if self.__showMarkdown: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
332 | self.__processingThread.process("markdown", fullText) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
333 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
334 | self.contents.setText(fullText) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
335 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
336 | def __setHtml(self, html): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
337 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
338 | 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
|
339 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
340 | @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
|
341 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
342 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
343 | self.contents.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
|
344 | |
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 | @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
|
346 | 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
|
347 | """ |
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 | 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
|
349 | |
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 | @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
|
351 | @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
|
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 | if not self.__shuttingDown and not self.__startingUp: |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
354 | self.contents.clear() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
355 | self.objectLineEdit.clear() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
356 | |
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
|
357 | 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
|
358 | if provider == self.__disabledProvider: |
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
|
359 | self.documentationReady(self.__disabledString) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
360 | 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
|
361 | 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
|
362 | |
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
|
363 | 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
|
364 | """ |
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
|
365 | 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
|
366 | """ |
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
|
367 | 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
|
368 | 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
|
369 | |
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
|
370 | 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
|
371 | """ |
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
|
372 | 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
|
373 | """ |
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
|
374 | 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
|
375 | if showMarkdown != self.__showMarkdown: |
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
|
376 | self.__showMarkdown = showMarkdown |
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
|
377 | self.documentationReady(self.__lastDocumentation) |
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
|
378 | |
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
|
379 | 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
|
380 | 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
|
381 | 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
|
382 | 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
|
383 | 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
|
384 | self.providerComboBox.setCurrentIndex(index) |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
385 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
386 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
387 | class DocumentProcessingThread(QThread): |
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 | 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
|
390 | viewer. |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
391 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
392 | @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
|
393 | 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
|
394 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
395 | htmlReady = pyqtSignal(str) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
396 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
397 | 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
|
398 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
399 | 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
|
400 | |
5912
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
401 | @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
|
402 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
403 | super(DocumentProcessingThread, self).__init__() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
404 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
405 | 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
|
406 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
407 | 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
|
408 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
409 | @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
|
410 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
411 | @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
|
412 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
413 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
414 | if self.wait(): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
415 | self.__language = language |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
416 | self.__text = text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
417 | self.start() |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
418 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
419 | def run(self): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
420 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
421 | 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
|
422 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
423 | language = self.__language |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
424 | text = self.__text |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
425 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
426 | if language == "markdown": |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
427 | 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
|
428 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
429 | html = "<html><body><p>" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
430 | 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
|
431 | html += "</p></body></html>" |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
432 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
433 | self.htmlReady.emit(html) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
434 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
435 | 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
|
436 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
437 | 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
|
438 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
439 | @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
|
440 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
441 | @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
|
442 | to HTML break |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
443 | @type bool |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
444 | @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
|
445 | @type str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
446 | @return processed HTML |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
447 | @rtype str |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
448 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
449 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
450 | import markdown # __IGNORE_EXCEPTION__ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
451 | except ImportError: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
452 | return self.tr( |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
453 | """<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
|
454 | """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
|
455 | """ '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
|
456 | """<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
|
457 | """installation instructions.</a></p>""") |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
458 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
459 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
460 | 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
|
461 | except ImportError: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
462 | # 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
|
463 | # as extension |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
464 | pass |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
465 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
466 | if convertNewLineToBreak: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
467 | 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
|
468 | else: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
469 | extensions = ['fenced_code', 'extra'] |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
470 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
471 | # 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
|
472 | 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
|
473 | (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
|
474 | 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
|
475 | class _StrikeThroughExtension(markdown.Extension): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
476 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
477 | 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
|
478 | 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
|
479 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
480 | (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
|
481 | this page for details) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
482 | """ |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
483 | DEL_RE = r'(~~)(.*?)~~' |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
484 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
485 | 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
|
486 | # Create the del pattern |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
487 | 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
|
488 | self.DEL_RE, 'del') |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
489 | # 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
|
490 | 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
|
491 | |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
492 | extensions.append(_StrikeThroughExtension()) |
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 | try: |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
495 | 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
|
496 | output_format=htmlFormat.lower()) |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
497 | except (ImportError, ValueError): |
b6643d36dddd
Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5911
diff
changeset
|
498 | # 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
|
499 | # 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
|
500 | # 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
|
501 | 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
|
502 | output_format=htmlFormat.lower()) |