{"action":"created","comment":{"url":"https://api.github.com/repos/hail-is/hail/pulls/comments/79704003","id":79704003,"diff_hunk":"@@ -0,0 +1,88 @@\n+#!/usr/bin/env node\n+\n+'use strict';\n+\n+process.on('uncaughtException', function (err) {\n+  console.log('Caught exception: ' + err);\n+  process.exit(1);\n+});\n+\n+const docsHtmlTemplate = __dirname + \"/\" + process.argv[2];\n+const jsonCommandsFile = process.argv[3];\n+const pandocOutputDir = __dirname + \"/\" + process.argv[4];\n+const compiledHTMLOutputFile = __dirname + \"/\" + process.argv[5];\n+\n+const jsdom = require('jsdom');\n+const fs = require('fs');\n+\n+var $ = null;\n+var buildDocs = require(\"./buildDocs.js\");\n+var mjAPI = require(\"mathjax-node/lib/mj-page.js\");\n+var jsonData = require(jsonCommandsFile);\n+\n+mjAPI.start();\n+\n+jsdom.env(docsHtmlTemplate, function (err, window) {\n+        window.addEventListener(\"error\", function (event) {\n+          console.error(\"script error!!\", event.error);\n+          process.exit(1);\n+        });\n+\n+        $ = require('jquery')(window);\n+\n+        function loadReq(selector, file) {\n+            return new Promise(function (resolve, reject) {\n+                $(selector).load(file, function (response, status, xhr) {\n+                    if (status == \"error\") {\n+                        console.log(\"error when loading file: \" + file);\n+                        reject(status)\n+                    } else {\n+                        resolve(response)\n+                    }\n+                    });\n+            });\n+        };\n+\n+        function error(message) {\n+            console.log(message);\n+            process.exit(1);\n+        }\n+\n+        var loadOverviewPromises = [loadReq(\"#Representation\", pandocOutputDir + \"Representation.html\"),\n+                                    loadReq(\"#ImportingGenotypeData\", pandocOutputDir + \"Importing.html\"),\n+                                    loadReq(\"#HailObjects\", pandocOutputDir + \"HailObjectProperties.html\"),\n+                                    loadReq(\"#Annotations\", pandocOutputDir + \"Annotations.html\"),\n+                                    loadReq(\"#HailExpressionLanguage\", pandocOutputDir + \"HailExpressionLanguage.html\"),\n+                                    loadReq(\"#Filtering\", pandocOutputDir + \"Filtering.html\"),\n+                                    loadReq(\"#ExportingData\", pandocOutputDir + \"ExportingData.html\"),\n+                                    loadReq(\"#ExportingTSV\", pandocOutputDir + \"ExportTSV.html\"),\n+                                    loadReq(\"#SQL\", pandocOutputDir + \"SQL.html\"),\n+                                    loadReq(\"#GettingStarted\", pandocOutputDir + \"GettingStarted.html\"),\n+                                    loadReq(\"#GlobalOptions\", pandocOutputDir + \"GlobalOptions.html\")\n+                                    ];\n+\n+        var buildCommandPromises = [];\n+        for (var commandName in jsonData.commands) {\n+            var data = jsonData.commands[commandName];\n+            if (!data.hidden) {\n+                buildCommandPromises.push(buildDocs.buildCommand(commandName, data, pandocOutputDir, $));\n+            }\n+        }","path":"docs/javascript/compileDocsNode.js","position":70,"original_position":70,"commit_id":"b548e51e2d50276101415a74a632266ea2686f2e","original_commit_id":"b548e51e2d50276101415a74a632266ea2686f2e","user":{"login":"danking","id":106194,"avatar_url":"https://avatars.githubusercontent.com/u/106194?v=3","gravatar_id":"","url":"https://api.github.com/users/danking","html_url":"https://github.com/danking","followers_url":"https://api.github.com/users/danking/followers","following_url":"https://api.github.com/users/danking/following{/other_user}","gists_url":"https://api.github.com/users/danking/gists{/gist_id}","starred_url":"https://api.github.com/users/danking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danking/subscriptions","organizations_url":"https://api.github.com/users/danking/orgs","repos_url":"https://api.github.com/users/danking/repos","events_url":"https://api.github.com/users/danking/events{/privacy}","received_events_url":"https://api.github.com/users/danking/received_events","type":"User","site_admin":false},"body":"Ah yeah. This is a bit painful because JS doesn't provide great primitives for mapping over objects. I tend to think of JSON objects more like instances of Java/Scala classes rather than hash maps, but that's not a widely shared viewpoint.\r\n\r\nA more functional approach could be achieved if `commandmeta` produced a list of objects for its `commands` field. Then you could do something like:\r\n\r\n```javascript\r\nconst buildCommandPromises = jsonData.commands\r\n  .filter(function(data) { return !data.isHidden })\r\n  .map(function (data) { buildDocs.buildCommand(data.name, data, pandocOutputDir, $) })\r\n```\r\n\r\nNote that I added the command name as a property on each command rather than as a field of the containing object.\r\n\r\nMoreover, I believe node.js defaults to EcmaScript 6 (ES6) which permits so-called \"arrow functions\" like this:\r\n\r\n```javascript\r\nconst buildCommandPromises = jsonData.commands\r\n  .filter(data => !data.isHidden)\r\n  .map(data => buildDocs.buildCommand(data.name, data, pandocOutputDir, $))\r\n```","created_at":"2016-09-20T20:27:07Z","updated_at":"2016-09-20T20:37:10Z","html_url":"https://github.com/hail-is/hail/pull/800#discussion_r79704003","pull_request_url":"https://api.github.com/repos/hail-is/hail/pulls/800","_links":{"self":{"href":"https://api.github.com/repos/hail-is/hail/pulls/comments/79704003"},"html":{"href":"https://github.com/hail-is/hail/pull/800#discussion_r79704003"},"pull_request":{"href":"https://api.github.com/repos/hail-is/hail/pulls/800"}}},"pull_request":{"url":"https://api.github.com/repos/hail-is/hail/pulls/800","id":85688833,"html_url":"https://github.com/hail-is/hail/pull/800","diff_url":"https://github.com/hail-is/hail/pull/800.diff","patch_url":"https://github.com/hail-is/hail/pull/800.patch","issue_url":"https://api.github.com/repos/hail-is/hail/issues/800","number":800,"state":"open","locked":false,"title":"Use NodeJS to compile docs for faster load times","user":{"login":"jigold","id":1693348,"avatar_url":"https://avatars.githubusercontent.com/u/1693348?v=3","gravatar_id":"","url":"https://api.github.com/users/jigold","html_url":"https://github.com/jigold","followers_url":"https://api.github.com/users/jigold/followers","following_url":"https://api.github.com/users/jigold/following{/other_user}","gists_url":"https://api.github.com/users/jigold/gists{/gist_id}","starred_url":"https://api.github.com/users/jigold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jigold/subscriptions","organizations_url":"https://api.github.com/users/jigold/orgs","repos_url":"https://api.github.com/users/jigold/repos","events_url":"https://api.github.com/users/jigold/events{/privacy}","received_events_url":"https://api.github.com/users/jigold/received_events","type":"User","site_admin":false},"body":" - Need to install npm on build server\r\n - Install following node packages: jsdom, jquery, mathjax-node\r\n - Set the Global Environment Variable for where Node packages are: $NODE_PATH","created_at":"2016-09-17T22:14:37Z","updated_at":"2016-09-20T20:37:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01ea1e67f4742d1fdb64fcbde403f72d4c860db5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hail-is/hail/pulls/800/commits","review_comments_url":"https://api.github.com/repos/hail-is/hail/pulls/800/comments","review_comment_url":"https://api.github.com/repos/hail-is/hail/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hail-is/hail/issues/800/comments","statuses_url":"https://api.github.com/repos/hail-is/hail/statuses/b548e51e2d50276101415a74a632266ea2686f2e","head":{"label":"jigold:jg_docsnode","ref":"jg_docsnode","sha":"b548e51e2d50276101415a74a632266ea2686f2e","user":{"login":"jigold","id":1693348,"avatar_url":"https://avatars.githubusercontent.com/u/1693348?v=3","gravatar_id":"","url":"https://api.github.com/users/jigold","html_url":"https://github.com/jigold","followers_url":"https://api.github.com/users/jigold/followers","following_url":"https://api.github.com/users/jigold/following{/other_user}","gists_url":"https://api.github.com/users/jigold/gists{/gist_id}","starred_url":"https://api.github.com/users/jigold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jigold/subscriptions","organizations_url":"https://api.github.com/users/jigold/orgs","repos_url":"https://api.github.com/users/jigold/repos","events_url":"https://api.github.com/users/jigold/events{/privacy}","received_events_url":"https://api.github.com/users/jigold/received_events","type":"User","site_admin":false},"repo":{"id":64695542,"name":"hail","full_name":"jigold/hail","owner":{"login":"jigold","id":1693348,"avatar_url":"https://avatars.githubusercontent.com/u/1693348?v=3","gravatar_id":"","url":"https://api.github.com/users/jigold","html_url":"https://github.com/jigold","followers_url":"https://api.github.com/users/jigold/followers","following_url":"https://api.github.com/users/jigold/following{/other_user}","gists_url":"https://api.github.com/users/jigold/gists{/gist_id}","starred_url":"https://api.github.com/users/jigold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jigold/subscriptions","organizations_url":"https://api.github.com/users/jigold/orgs","repos_url":"https://api.github.com/users/jigold/repos","events_url":"https://api.github.com/users/jigold/events{/privacy}","received_events_url":"https://api.github.com/users/jigold/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jigold/hail","description":"Hail, a framework for scalable genetic data analysis","fork":true,"url":"https://api.github.com/repos/jigold/hail","forks_url":"https://api.github.com/repos/jigold/hail/forks","keys_url":"https://api.github.com/repos/jigold/hail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jigold/hail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jigold/hail/teams","hooks_url":"https://api.github.com/repos/jigold/hail/hooks","issue_events_url":"https://api.github.com/repos/jigold/hail/issues/events{/number}","events_url":"https://api.github.com/repos/jigold/hail/events","assignees_url":"https://api.github.com/repos/jigold/hail/assignees{/user}","branches_url":"https://api.github.com/repos/jigold/hail/branches{/branch}","tags_url":"https://api.github.com/repos/jigold/hail/tags","blobs_url":"https://api.github.com/repos/jigold/hail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jigold/hail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jigold/hail/git/refs{/sha}","trees_url":"https://api.github.com/repos/jigold/hail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jigold/hail/statuses/{sha}","languages_url":"https://api.github.com/repos/jigold/hail/languages","stargazers_url":"https://api.github.com/repos/jigold/hail/stargazers","contributors_url":"https://api.github.com/repos/jigold/hail/contributors","subscribers_url":"https://api.github.com/repos/jigold/hail/subscribers","subscription_url":"https://api.github.com/repos/jigold/hail/subscription","commits_url":"https://api.github.com/repos/jigold/hail/commits{/sha}","git_commits_url":"https://api.github.com/repos/jigold/hail/git/commits{/sha}","comments_url":"https://api.github.com/repos/jigold/hail/comments{/number}","issue_comment_url":"https://api.github.com/repos/jigold/hail/issues/comments{/number}","contents_url":"https://api.github.com/repos/jigold/hail/contents/{+path}","compare_url":"https://api.github.com/repos/jigold/hail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jigold/hail/merges","archive_url":"https://api.github.com/repos/jigold/hail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jigold/hail/downloads","issues_url":"https://api.github.com/repos/jigold/hail/issues{/number}","pulls_url":"https://api.github.com/repos/jigold/hail/pulls{/number}","milestones_url":"https://api.github.com/repos/jigold/hail/milestones{/number}","notifications_url":"https://api.github.com/repos/jigold/hail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jigold/hail/labels{/name}","releases_url":"https://api.github.com/repos/jigold/hail/releases{/id}","deployments_url":"https://api.github.com/repos/jigold/hail/deployments","created_at":"2016-08-01T19:28:56Z","updated_at":"2016-08-01T19:28:58Z","pushed_at":"2016-09-20T18:17:36Z","git_url":"git://github.com/jigold/hail.git","ssh_url":"git@github.com:jigold/hail.git","clone_url":"https://github.com/jigold/hail.git","svn_url":"https://github.com/jigold/hail","homepage":"","size":12512,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hail-is:master","ref":"master","sha":"fac7e9906c674b2aea4b4633db040d919cce2277","user":{"login":"hail-is","id":20861792,"avatar_url":"https://avatars.githubusercontent.com/u/20861792?v=3","gravatar_id":"","url":"https://api.github.com/users/hail-is","html_url":"https://github.com/hail-is","followers_url":"https://api.github.com/users/hail-is/followers","following_url":"https://api.github.com/users/hail-is/following{/other_user}","gists_url":"https://api.github.com/users/hail-is/gists{/gist_id}","starred_url":"https://api.github.com/users/hail-is/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hail-is/subscriptions","organizations_url":"https://api.github.com/users/hail-is/orgs","repos_url":"https://api.github.com/users/hail-is/repos","events_url":"https://api.github.com/users/hail-is/events{/privacy}","received_events_url":"https://api.github.com/users/hail-is/received_events","type":"Organization","site_admin":false},"repo":{"id":45069467,"name":"hail","full_name":"hail-is/hail","owner":{"login":"hail-is","id":20861792,"avatar_url":"https://avatars.githubusercontent.com/u/20861792?v=3","gravatar_id":"","url":"https://api.github.com/users/hail-is","html_url":"https://github.com/hail-is","followers_url":"https://api.github.com/users/hail-is/followers","following_url":"https://api.github.com/users/hail-is/following{/other_user}","gists_url":"https://api.github.com/users/hail-is/gists{/gist_id}","starred_url":"https://api.github.com/users/hail-is/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hail-is/subscriptions","organizations_url":"https://api.github.com/users/hail-is/orgs","repos_url":"https://api.github.com/users/hail-is/repos","events_url":"https://api.github.com/users/hail-is/events{/privacy}","received_events_url":"https://api.github.com/users/hail-is/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hail-is/hail","description":"Scalable genetic data analysis","fork":false,"url":"https://api.github.com/repos/hail-is/hail","forks_url":"https://api.github.com/repos/hail-is/hail/forks","keys_url":"https://api.github.com/repos/hail-is/hail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hail-is/hail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hail-is/hail/teams","hooks_url":"https://api.github.com/repos/hail-is/hail/hooks","issue_events_url":"https://api.github.com/repos/hail-is/hail/issues/events{/number}","events_url":"https://api.github.com/repos/hail-is/hail/events","assignees_url":"https://api.github.com/repos/hail-is/hail/assignees{/user}","branches_url":"https://api.github.com/repos/hail-is/hail/branches{/branch}","tags_url":"https://api.github.com/repos/hail-is/hail/tags","blobs_url":"https://api.github.com/repos/hail-is/hail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hail-is/hail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hail-is/hail/git/refs{/sha}","trees_url":"https://api.github.com/repos/hail-is/hail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hail-is/hail/statuses/{sha}","languages_url":"https://api.github.com/repos/hail-is/hail/languages","stargazers_url":"https://api.github.com/repos/hail-is/hail/stargazers","contributors_url":"https://api.github.com/repos/hail-is/hail/contributors","subscribers_url":"https://api.github.com/repos/hail-is/hail/subscribers","subscription_url":"https://api.github.com/repos/hail-is/hail/subscription","commits_url":"https://api.github.com/repos/hail-is/hail/commits{/sha}","git_commits_url":"https://api.github.com/repos/hail-is/hail/git/commits{/sha}","comments_url":"https://api.github.com/repos/hail-is/hail/comments{/number}","issue_comment_url":"https://api.github.com/repos/hail-is/hail/issues/comments{/number}","contents_url":"https://api.github.com/repos/hail-is/hail/contents/{+path}","compare_url":"https://api.github.com/repos/hail-is/hail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hail-is/hail/merges","archive_url":"https://api.github.com/repos/hail-is/hail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hail-is/hail/downloads","issues_url":"https://api.github.com/repos/hail-is/hail/issues{/number}","pulls_url":"https://api.github.com/repos/hail-is/hail/pulls{/number}","milestones_url":"https://api.github.com/repos/hail-is/hail/milestones{/number}","notifications_url":"https://api.github.com/repos/hail-is/hail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hail-is/hail/labels{/name}","releases_url":"https://api.github.com/repos/hail-is/hail/releases{/id}","deployments_url":"https://api.github.com/repos/hail-is/hail/deployments","created_at":"2015-10-27T20:55:42Z","updated_at":"2016-09-19T20:14:01Z","pushed_at":"2016-09-20T20:32:09Z","git_url":"git://github.com/hail-is/hail.git","ssh_url":"git@github.com:hail-is/hail.git","clone_url":"https://github.com/hail-is/hail.git","svn_url":"https://github.com/hail-is/hail","homepage":"https://hail.is","size":7729,"stargazers_count":52,"watchers_count":52,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":232,"forks":23,"open_issues":232,"watchers":52,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hail-is/hail/pulls/800"},"html":{"href":"https://github.com/hail-is/hail/pull/800"},"issue":{"href":"https://api.github.com/repos/hail-is/hail/issues/800"},"comments":{"href":"https://api.github.com/repos/hail-is/hail/issues/800/comments"},"review_comments":{"href":"https://api.github.com/repos/hail-is/hail/pulls/800/comments"},"review_comment":{"href":"https://api.github.com/repos/hail-is/hail/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hail-is/hail/pulls/800/commits"},"statuses":{"href":"https://api.github.com/repos/hail-is/hail/statuses/b548e51e2d50276101415a74a632266ea2686f2e"}}}}
{"actor":{"display_login":"danking"}}