-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethodList.py
124 lines (99 loc) · 5.68 KB
/
MethodList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from .MethodListDocs.javalist import getMethods
from .MethodListDocs.pythonlist import getPythonFunc
from .MethodListDocs.rubylist import getRubyFunc
from .MethodListDocs.webfuncattr import getWebFunc
import sublime, sublime_plugin, re, webbrowser
css = (
"html {background-color: #1B1B17; color: #eefbee; padding: 2px; }" +
"body {font-size: 11px; border-color: red;}" +
"b {color: #22aa22; }" +
"a {color: hotpink; }" +
"h1 {color: #cccccc; font-weight: bold; font-size: 14px; }"
)
class Method_listCommand(sublime_plugin.WindowCommand):
def run(self):
sublime.set_timeout_async(self.getData, 0)
def getData(self):
window = self.window
view = window.active_view()
selText = view.sel()[0]
xt = str(window.active_view().file_name())
scope = (view.scope_name(0).split(" ")[0].split(".")[1])
selected = view.substr(selText)
try:
if scope == "java":
doc = getMethods(selected)[0]
url = getMethods(selected)[1]
sublime.status_message("Searching for methods ...")
try:
doc = "<h1>%s</h1><br>%s<br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, doc.replace("\n", "<br>"), url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s Fields and Methods\n\n%s \n\nRead more at: \"%s\"" % (selected, doc, url)
sublime.message_dialog(doc)
elif scope == "ruby":
result = getRubyFunc(selected)[0]
url = getRubyFunc(selected)[1]
try:
doc = "<h1>%s Methods</h1><br>%s ... <br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, result.replace("\n", "<br>"), url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s Fields and Methods\n\n%s ... \n\nRead more at: \"%s\"" % (selected, result, url)
sublime.message_dialog(doc)
elif scope == "html":
url = getWebFunc(selected, "html")[0]
result = getWebFunc(selected, "html")[1]
if len(result) > 2:
try:
doc = "<h1>%s Attributes</h1><br>%s <br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, result.replace("\n", "<br>"), url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s Fields and Methods\n\n%s\n\nRead more at: \"%s\"" % (selected, result, url)
sublime.message_dialog(doc)
else:
sublime.status_message("LangDocs: Can't find attributes")
elif scope == "css":
url = str(getWebFunc(selected, "css")[0])
result = getWebFunc(selected, "css")[1]
if len(result) > 2:
sublime.status_message("Reading documentation ...")
try:
doc = "<h1>%s values</h1><br>%s<br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, result, url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s values\n\n%s \n\nRead more at: \"%s\"" % (selected, result, url)
sublime.message_dialog(doc)
elif scope == "js":
url = str(getWebFunc(selected, "javascript")[0])
result = getWebFunc(selected, "javascript")[1]
if len(result) > 2:
sublime.status_message("Reading documentation ...")
try:
doc = "<h1>%s Method and Properties</h1><br>%s<br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, result, url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s Methods and properties\n\n%s \n\nRead more at: \"%s\"" % (selected, result, url)
sublime.message_dialog(doc)
elif scope == "python":
mainlist = getPythonFunc(selected)[0]
otherlist = getPythonFunc(selected)[1]
url = getPythonFunc(selected)[2]
sublime.status_message("Reading documentation ...")
try:
doc = "<h1>%s Method Lists</h1><br>%s <br><br><h1>%s Constants and Others </h1><br>%s <br><br>Read more at: \"<a href=\"%s\">%s<a>\"" % (selected, mainlist, selected, otherlist, url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
if len(mainlist) > 0:
doc = "%s Method Lists\n\n%s ... \n\nRead more at: \"%s\"" % (selected, mainlist, url)
sublime.message_dialog(doc)
if len(otherlist) > 0:
doc = "%s Constants and others\n\n%s \n\nRead more at: \"%s\"" % (selected, otherlist, url)
sublime.message_dialog(doc)
except:
sublime.status_message("Can't find result")