def get_page(name): page = bs4.BeautifulSoup(omnidoc.urlopen(page_url_format.format(name))) members = bs4.BeautifulSoup(omnidoc.urlopen(listpage_url_format.format(name))) title, hint = page.title.get_text().partition('|')[0].strip().split()[:2] for k in header(title=title, hint=hint, completion=title, doc_url=page_url_format.format(name)): yield k desc = page.find('h1', class_='title').find_next_sibling('p').get_text() desc = remove_trailing('More...', desc) yield omnidoc.Entry(label='Description', desc=omnidoc.wrap(desc), action=None) for li in members.find_all('li',class_='fn'): name = li.find('span', class_='name').get_text() sig = li.get_text() yield omnidoc.Entry(label=name, desc=sig, action=omnidoc.Insert(name))
def get_page(name): doc_url = PAGE_URL_FORMAT.format(name) soup = bs4.BeautifulSoup(omnidoc.urlopen(doc_url).read()) title, _, desc = soup.find(class_='refnamediv').p.get_text().partition(u'—') title, desc = map(unicode.strip, (title, desc)) completion = soup.find('div', class_='funcsynopsis').get_text() for k in header(title, desc, completion, doc_url): yield k variablelist = soup.find(class_='variablelist') if variablelist: yield omnidoc.Entry( label=omnidoc.whitespace.pad+'Parameters:', desc=None, action=None) for dt in variablelist.dl.find_all('dt', recursive=False): dd = dt.find_next_sibling('dd') name, desc = dt.get_text().strip(), dd.get_text().strip() # OGL is a bit crazy with spaces, so name = ' '.join(name.split()) desc = ' '.join(desc.split()) yield omnidoc.Entry(name, desc, omnidoc.Insert(name))
def get_index(): soup = bs4.BeautifulSoup(omnidoc.urlopen(index_url)) for dd in soup.find('div',class_='descr').find_all('dd'): a = dd.a if a is None: continue yield omnidoc.Entry(label=a.get_text().strip(), desc=None, action=omnidoc.Navigate(prefix+':'+a['href'][:-5]))
def get_index(): soup = bs4.BeautifulSoup(omnidoc.urlopen(BASE_URL).read()) for link in soup('a', target='pagedisp'): name = link.get_text() yield omnidoc.Entry( label=name, desc=None, action=omnidoc.Navigate(prefix+':'+name) )
def get_page_old(name): # This old attempt parses thorugh the class page, not the 'all members' page. # Could get more info (about signals, slots etc), but doesn't catch inherited members. Nope. soup = bs4.BeautifulSoup(omnidoc.urlopen(page_url_format.format(name))) title, hint = soup.title.get_text().partition('|')[2].strip().split()[:2] for k in header( title = title, hint = hint, completion = title, doc_url = page_url_format.format(name)): yield k for h3 in soup.find('div', class_='func').find_all('h3', class_='fn'): yield h3_to_page(h3, title)
def get_page_column_init(): column = bs4.BeautifulSoup(omnidoc.urlopen('http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html')) fieldlist = column.find('dt', id='sqlalchemy.schema.Column.__init__').parent.find('table',class_='field-list') return read_fieldlist(fieldlist)
def get_page_column(): column = bs4.BeautifulSoup(omnidoc.urlopen('http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html')) parent = column.find('dt', id='sqlalchemy.schema.Column').parent return read_type(parent)
def get_page_relation(): relationship = bs4.BeautifulSoup(omnidoc.urlopen('http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html')) fieldlist = relationship.find(class_='field-list') return read_fieldlist(fieldlist)
def get_page_query(): query = bs4.BeautifulSoup(omnidoc.urlopen('http://docs.sqlalchemy.org/en/rel_0_8/orm/query.html')) return read_type(query)