-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathDocumentation for Current Word.tmCommand
More file actions
84 lines (77 loc) · 2.74 KB
/
Documentation for Current Word.tmCommand
File metadata and controls
84 lines (77 loc) · 2.74 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/bin/bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
# set up TM_FIRST_LINE containing the first line of the script.
read first_line
0<&- # close STDIN
export TM_FIRST_LINE="$first_line"
export PYTHONPATH="$TM_BUNDLE_SUPPORT/DocMate"
export PYTHONPATH="$TM_SUPPORT_PATH/lib:$PYTHONPATH"
/usr/bin/python -S - <<PYTHON
# coding: UTF-8
import sys
from sys import exit
import tm_helpers
import webpreview
import docmate
import dialog
docmate.launch_pydoc_server()
# get current dotted word from the env
word = tm_helpers.current_word(r"[A-Za-z0-9_\.]*")
if not word:
print "<meta http-equiv='Refresh' content='0;URL=%s'>" % docmate.pydoc_url()[0]
else:
library_docs = docmate.library_docs(word)
local_docs = docmate.local_docs(word)
if library_docs:
print webpreview.html_header("DocMate", "Python")
print "<h3>Python Library Documentation</h3>\n"
print "<ol style='list-style-type: lower-alpha;'>\n"
for n, opt in enumerate(library_docs):
desc, url = opt
accesskey = chr(ord("a") + n)
print '\t<li><a href="%s" accesskey="%s">%s</a></li>\n' % (url, accesskey, desc)
print "</ol>\n"
if local_docs and library_docs:
print "<h3>Pydoc Documentation</h3>"
print "<ol style='list-style-type: decimal;'>\n"
for n, opt in enumerate(local_docs):
desc, url = opt
accesskey = chr(ord("1") + n)
print '\t<li><a href="%s" accesskey="%s">%s</a></li>\n' % (url, accesskey, desc)
print "</ol>\n"
print webpreview.html_footer()
elif local_docs and not library_docs:
print "<meta http-equiv='Refresh' content='0;URL=%s'>" % local_docs[0][1]
else:
print "<meta http-equiv='Refresh' content='0;URL=%s'>" % docmate.pydoc_url()[0]
PYTHON
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^h</string>
<key>name</key>
<string>Documentation for Current Word</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>html</string>
<key>outputLocation</key>
<string>newWindow</string>
<key>scope</key>
<string>source.python</string>
<key>uuid</key>
<string>443BBF21-6124-4486-BFCA-D18606465885</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>