Skip to content

Commit

Permalink
Updated for Houdini 16
Browse files Browse the repository at this point in the history
Added new functions and expressions.
C++ raw strings support.
Improved syntax highlighting.
  • Loading branch information
teared committed Feb 27, 2017
1 parent 30a9211 commit 9369e3f
Show file tree
Hide file tree
Showing 12 changed files with 11,198 additions and 4,629 deletions.
1 change: 0 additions & 1 deletion VEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
allow_exts = (
'.css',
'.json',
'.md',
'.py',
'.sublime-commands',
'.sublime-completions',
Expand Down
2,108 changes: 1,085 additions & 1,023 deletions commands/helpcards.json

Large diffs are not rendered by default.

110 changes: 67 additions & 43 deletions develop/expressions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"384\n",
"poppointid\n",
"{'argnames': ('particle_id', 'attribute', 'index'),\n",
" 'args': ('float', 'string', 'float'),\n",
"390\n",
"hasvertexattrib\n",
"{'argnames': ('surface_node', 'attribute'),\n",
" 'args': ('string', 'string'),\n",
" 'return': 'float'}\n"
]
}
Expand Down Expand Up @@ -115,11 +115,15 @@
"float chrampt(string ramp_path, float position, float component_index, float time)\n",
"string chs(string channel)\n",
"string chsop(string path)\n",
"string chsoplist(string path) \n",
"string chsraw(string channel)\n",
"float cht(string channel, float time)\n",
"float clamp(float value, float minimum, float maximum)\n",
"float clamptosphere(float x, float y, float z, float min_radius, float max_radius, string constant_type)\n",
"float constant()\n",
"string cophasmeta(string compositing_node, string metadata_name)\n",
"float copmeta(string compositing_node, string metadata_name, float index) \n",
"string copmetas(string compositing_node, string metadata_name)\n",
"float cos(float number)\n",
"float cosh(float number)\n",
"vector cross(vector v1, vector v2)\n",
Expand Down Expand Up @@ -306,7 +310,10 @@
"string oppwf()\n",
"string oprelativepath(string srcpath, string destpath)\n",
"string opselect(string network)\n",
"string opselectpath(string network)\n",
"string opselectrecurse(string network, float flag) \n",
"string opselectrecurse(string network, float flag)\n",
"string opstreamname(string nodepath)\n",
"string opsubpath(string node)\n",
"matrix optransform(string object_name)\n",
"string optype(string name)\n",
Expand Down Expand Up @@ -367,9 +374,9 @@
"float qlinear()\n",
"matrix quattomatrix(vector q)\n",
"float quintic()\n",
"float raw()\n",
"float rad(float number)\n",
"float rand(float value)\n",
"float raw()\n",
"float realuv(string surface_node, float prim_num, float uv_unit, float D_U|D_V)\n",
"float repeat(float f1, float f2)\n",
"float repeatt(float t1, float t2)\n",
Expand Down Expand Up @@ -521,7 +528,7 @@
"Loaded 325 pages.\n",
"Loaded 350 pages.\n",
"Loaded 375 pages.\n",
"Loaded 382 pages.\n"
"Loaded 387 pages.\n"
]
}
],
Expand Down Expand Up @@ -577,7 +584,7 @@
"Finished 325 helpcards.\n",
"Finished 350 helpcards.\n",
"Finished 375 helpcards.\n",
"Finished 382 helpcards.\n"
"Finished 387 helpcards.\n"
]
}
],
Expand All @@ -586,8 +593,7 @@
" global expressions, pages\n",
" index = 'https://www.sidefx.com/docs/houdini/expressions/'\n",
" s = bs4.BeautifulSoup(pages[f], 'html.parser')\n",
" meta, = s.select('#meta')\n",
" nonmeta, = s.select('#nonmeta')\n",
" nonmeta, = s.main.select('#content')\n",
" nonmeta['id'] = 'helpcard'\n",
"\n",
" # Strip redundant tags which does not work good inside ST3 popups.\n",
Expand All @@ -598,17 +604,55 @@
" var.wrap(s.new_tag('code'))\n",
" var.unwrap()\n",
" for div in nonmeta.find_all('div', class_='def'):\n",
" div.wrap(s.new_tag('p'))\n",
" div.unwrap()\n",
" for div in nonmeta.find_all('div', class_='content'):\n",
" if not div.text.strip():\n",
" div.unwrap()\n",
" for div in nonmeta.find_all('div', class_='clear'):\n",
" div.unwrap()\n",
" for code in nonmeta.find_all('code', class_='codehilite'):\n",
" code.unwrap()\n",
" for p in nonmeta.find_all('p', class_='label'):\n",
" p.unwrap()\n",
" for tag in nonmeta.find_all(['pre', 'dl', 'span', 'section']):\n",
" tag.unwrap()\n",
"\n",
" # Append related section.\n",
" related = s.main.select('#postmeta')[0].select('a.Exp')\n",
" if related:\n",
" h = s.new_tag('h2')\n",
" h.string = 'See also'\n",
" nonmeta.append(h)\n",
"\n",
" for a in related:\n",
" title = a.get('title')\n",
" text = a.text\n",
" a = s.new_tag('a', href=index+a['href'])\n",
" a.string = text\n",
"\n",
" p = s.new_tag('p')\n",
" p.append(a)\n",
"\n",
" if title:\n",
" div = s.new_tag('div', **{'class': 'related-summary'})\n",
" div.string = title\n",
" p.append(div)\n",
"\n",
" nonmeta.append(p)\n",
"\n",
" for table in nonmeta.find_all('table'):\n",
" table.decompose()\n",
" \n",
" # Destroy default documentation signatures.\n",
" # TODO: Remove small indents in ST3 caused by properly formatted HTML code by removing '\\n' strings.\n",
" for c in nonmeta.children:\n",
" if c != '\\n':\n",
" if (c.name == 'ul' and 'bullets' in c['class']) \\\n",
" or (c.name == 'div' and 'usage_group' in c['class']):\n",
" c.decompose()\n",
" break\n",
"\n",
" # Make URLs full.\n",
" for a in nonmeta.find_all('a'):\n",
" a['href'] = index + a['href']\n",
Expand All @@ -625,18 +669,13 @@
" newtext = code.text.lstrip(' ')\n",
" code.string = '\\xa0' * (len(code.text)-len(newtext)) + newtext\n",
"\n",
" # Store summary tag for future work.\n",
" summary = nonmeta.find('p', class_='summary')\n",
" # Add summary paragraph.\n",
" summary = s.main.select('.summary')\n",
" if not summary:\n",
" summary = s.new_tag('p', **{'class': 'summary'})\n",
" nonmeta.insert(0, summary)\n",
" \n",
" # Destroy default documentation signature.\n",
" sigs = summary.next_sibling\n",
" if sigs and sigs == '\\n':\n",
" sigs = sigs.next_sibling\n",
" if sigs and sigs.name == 'ul':\n",
" sigs.decompose()\n",
" else:\n",
" summary = summary[0]\n",
" nonmeta.insert(0, summary)\n",
" \n",
" # Insert function signature from read list.\n",
" code = s.new_tag('code')\n",
Expand All @@ -655,36 +694,21 @@
" heading = s.new_tag('h1')\n",
" heading.append(title)\n",
" summary.insert_before(heading)\n",
" \n",
" # Append related section.\n",
" related = meta.select('a.Exp')\n",
" if related:\n",
" h = s.new_tag('h2')\n",
" h.string = 'Related'\n",
" nonmeta.append(h)\n",
"\n",
" for a in related:\n",
" title = a.get('title')\n",
" text = a.text\n",
" a = s.new_tag('a', href=index+a['href'])\n",
" a.string = text\n",
"\n",
" p = s.new_tag('p')\n",
" p.append(a)\n",
"\n",
" if title:\n",
" div = s.new_tag('div', **{'class': 'related-summary'})\n",
" div.string = title\n",
" p.append(div)\n",
"\n",
" nonmeta.append(p)\n",
"\n",
" # print(nonmeta.prettify())\n",
" return str(nonmeta)\n",
"\n",
"# # For quick testing.\n",
"# with open('../commands/helpcards.json', 'w') as f:\n",
"# helpcards = {\n",
"# 'hscript': {\n",
"# 'chope' : make_helpcard('point'),\n",
"# 'opinput' : make_helpcard('opinput'),\n",
"# }\n",
"# }\n",
"# json.dump(helpcards, f, indent=4, sort_keys=True)\n",
"\n",
"helpcards = {}\n",
"\n",
"for i, f in enumerate(sorted(pages)):\n",
" try:\n",
" helpcard = make_helpcard(f)\n",
Expand Down
Loading

0 comments on commit 9369e3f

Please sign in to comment.