Last active
February 22, 2018 12:05
-
-
Save yanqiw/11997e2a0a7fc4cb64c7f6b4cad19248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import os, re, sqlite3 | |
from bs4 import BeautifulSoup, NavigableString, Tag | |
db = sqlite3.connect('loopback.docset/Contents/Resources/docSet.dsidx') | |
cur = db.cursor() | |
try: cur.execute('DROP TABLE searchIndex;') | |
except: pass | |
cur.execute('CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);') | |
cur.execute('CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);') | |
docpath = 'loopback.docset/Contents/Resources/Documents/apidocs.strongloop.com/loopback/v/2.29.0' | |
#loopback.docset/Contents/Resources/Documents/apidocs.strongloop.com/loopback/v/2.29.0 | |
page = open(os.path.join(docpath,'','index.html')).read() | |
soup = BeautifulSoup(page) | |
any = re.compile('.*') | |
for tag in soup.find_all('a', {'href':any}): | |
name = tag.text.strip() | |
if len(name) > 0: | |
path = tag.attrs['href'].strip() | |
if path.split('#')[0] in ('index.html'): | |
cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (name.replace('\n',''), 'func', '/apidocs.strongloop.com/loopback/v/2.29.0/'+path)) | |
print 'name: %s, path: %s' % (name.replace('\n',''), path) | |
db.commit() | |
db.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
哦,dash中的那个loopback是你生成的啊,,,
现在到2.31.0了,而且其他modules还没有,是用相同的方法做吗?
另外,我看你 Dash-User-Contributions/docsets/Loopback at master · Kapeli/Dash-User-Contributions这里的最终成果是tgz.txt啊,,,,这里我有点看不明白呢
你之前问的 dash doc of loopback - Google Groups 是不是没有?
现在strongloop也是你厂的了,,,,应该要文档还算轻松吧?:joy: 什么apic,什么pm之类的文档要是都有就好了
感谢你做的文档!