{"action":"created","comment":{"url":"https://api.github.com/repos/api-platform/website/pulls/comments/198811587","pull_request_review_id":132800113,"id":198811587,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODgxMTU4Nw==","diff_hunk":"@@ -1,52 +1,22 @@\n #!/usr/bin/env node\n \n-const fs = require('fs');\n-const { markdown } = require('markdown');\n-const path = require('path');\n-const xpath = require('xpath');\n-const yaml = require('js-yaml');\n-const { DOMParser } = require('xmldom');\n+const fileProcessor = require('./fileProcessor');\n+const { readFileSync, writeFile } = require('fs');\n+const { resolve } = require('path');\n+const jsyaml = require('js-yaml');\n \n-let content = fs.readFileSync(path.resolve(__dirname, '../src/pages/docs/index.md')).toString();\n-content = content.replace(/`/gm, '\"');\n-content = markdown.toHTML(content);\n+const loadedOutline = jsyaml.safeLoad(readFileSync(`${__dirname}/../config/outline.yaml`, 'utf8'));\n \n-const html = new DOMParser().parseFromString(content);\n+let yaml = '';\n \n-const guessPath = h2 => xpath.select('following-sibling::ol[1]/li[1]/a/@href', h2)[0].value.split('/')[0];\n+loadedOutline.forEach((directory) => {\n+  const fileTree = directory.items.map(file =>\n+    fileProcessor.processFile(directory.path, file.id)[0]);\n \n-const normalizeAnchors = anchors =>\n-  anchors.map(anchor => ({\n-    id: xpath.select('./a/@href', anchor)[0].value.split('#')[1],\n-    title: xpath.select('./a', anchor)[0].firstChild.data,\n-  }));\n+  yaml += jsyaml.safeDump([{ ...directory, items: fileTree }], { lineWidth: 255 });\n+});\n \n-const normalizeItems = items =>\n-  items.map((item) => {\n-    const id = xpath.select('./a/@href', item)[0].value.replace('.md', '').split('/')[1];\n-    const title = normalizeTitle(xpath.select('./a', item)[0].firstChild.data);\n-\n-    const anchors = xpath.select('./ol/li', item);\n-    if (0 === anchors.length) {\n-      return {\n-        id,\n-        title,\n-      };\n-    }\n-\n-    return {\n-      id,\n-      title,\n-      anchors: normalizeAnchors(anchors),\n-    };\n-  });\n-\n-const normalizeTitle = title => title.trim().split(':')[0];\n-\n-const results = xpath.select('//h2', html).map(h2 => ({\n-  title: normalizeTitle(h2.firstChild.data),\n-  path: guessPath(h2),\n-  items: normalizeItems(xpath.select('following-sibling::ol[1]/li', h2)),\n-}));\n-\n-fs.writeFile(path.resolve(__dirname, '../src/pages/docs/nav.yml'), yaml.dump(results), error => error && console.warn(error));\n+writeFile(","path":"bin/generate-nav","position":64,"original_position":64,"commit_id":"ff1928006421e396e8d7a16a0242f0c195bcfb45","original_commit_id":"ff1928006421e396e8d7a16a0242f0c195bcfb45","user":{"login":"toofff","id":966550,"node_id":"MDQ6VXNlcjk2NjU1MA==","avatar_url":"https://avatars0.githubusercontent.com/u/966550?v=4","gravatar_id":"","url":"https://api.github.com/users/toofff","html_url":"https://github.com/toofff","followers_url":"https://api.github.com/users/toofff/followers","following_url":"https://api.github.com/users/toofff/following{/other_user}","gists_url":"https://api.github.com/users/toofff/gists{/gist_id}","starred_url":"https://api.github.com/users/toofff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toofff/subscriptions","organizations_url":"https://api.github.com/users/toofff/orgs","repos_url":"https://api.github.com/users/toofff/repos","events_url":"https://api.github.com/users/toofff/events{/privacy}","received_events_url":"https://api.github.com/users/toofff/received_events","type":"User","site_admin":false},"body":"`writeFile(resolve(__dirname, '../src/pages/docs/nav.yml'), yaml, (error) => error && console.warn(error));`","created_at":"2018-06-28T11:48:12Z","updated_at":"2018-06-28T12:01:40Z","html_url":"https://github.com/api-platform/website/pull/42#discussion_r198811587","pull_request_url":"https://api.github.com/repos/api-platform/website/pulls/42","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/api-platform/website/pulls/comments/198811587"},"html":{"href":"https://github.com/api-platform/website/pull/42#discussion_r198811587"},"pull_request":{"href":"https://api.github.com/repos/api-platform/website/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/api-platform/website/pulls/42","id":193562850,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzNTYyODUw","html_url":"https://github.com/api-platform/website/pull/42","diff_url":"https://github.com/api-platform/website/pull/42.diff","patch_url":"https://github.com/api-platform/website/pull/42.patch","issue_url":"https://api.github.com/repos/api-platform/website/issues/42","number":42,"state":"open","locked":false,"title":"Feature/improve nav generation script and add outline file","user":{"login":"Mathieudewet","id":10513229,"node_id":"MDQ6VXNlcjEwNTEzMjI5","avatar_url":"https://avatars0.githubusercontent.com/u/10513229?v=4","gravatar_id":"","url":"https://api.github.com/users/Mathieudewet","html_url":"https://github.com/Mathieudewet","followers_url":"https://api.github.com/users/Mathieudewet/followers","following_url":"https://api.github.com/users/Mathieudewet/following{/other_user}","gists_url":"https://api.github.com/users/Mathieudewet/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathieudewet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathieudewet/subscriptions","organizations_url":"https://api.github.com/users/Mathieudewet/orgs","repos_url":"https://api.github.com/users/Mathieudewet/repos","events_url":"https://api.github.com/users/Mathieudewet/events{/privacy}","received_events_url":"https://api.github.com/users/Mathieudewet/received_events","type":"User","site_admin":false},"body":"Update doc generation scripts. ","created_at":"2018-06-08T09:48:09Z","updated_at":"2018-06-28T12:01:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fb6f600fd17ec19ed42f7a046b6443bd23a8ba8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/api-platform/website/pulls/42/commits","review_comments_url":"https://api.github.com/repos/api-platform/website/pulls/42/comments","review_comment_url":"https://api.github.com/repos/api-platform/website/pulls/comments{/number}","comments_url":"https://api.github.com/repos/api-platform/website/issues/42/comments","statuses_url":"https://api.github.com/repos/api-platform/website/statuses/ff1928006421e396e8d7a16a0242f0c195bcfb45","head":{"label":"Mathieudewet:feature/improve-nav-generation-script-and-add-outline-file","ref":"feature/improve-nav-generation-script-and-add-outline-file","sha":"ff1928006421e396e8d7a16a0242f0c195bcfb45","user":{"login":"Mathieudewet","id":10513229,"node_id":"MDQ6VXNlcjEwNTEzMjI5","avatar_url":"https://avatars0.githubusercontent.com/u/10513229?v=4","gravatar_id":"","url":"https://api.github.com/users/Mathieudewet","html_url":"https://github.com/Mathieudewet","followers_url":"https://api.github.com/users/Mathieudewet/followers","following_url":"https://api.github.com/users/Mathieudewet/following{/other_user}","gists_url":"https://api.github.com/users/Mathieudewet/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathieudewet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathieudewet/subscriptions","organizations_url":"https://api.github.com/users/Mathieudewet/orgs","repos_url":"https://api.github.com/users/Mathieudewet/repos","events_url":"https://api.github.com/users/Mathieudewet/events{/privacy}","received_events_url":"https://api.github.com/users/Mathieudewet/received_events","type":"User","site_admin":false},"repo":{"id":133945849,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM5NDU4NDk=","name":"website","full_name":"Mathieudewet/website","owner":{"login":"Mathieudewet","id":10513229,"node_id":"MDQ6VXNlcjEwNTEzMjI5","avatar_url":"https://avatars0.githubusercontent.com/u/10513229?v=4","gravatar_id":"","url":"https://api.github.com/users/Mathieudewet","html_url":"https://github.com/Mathieudewet","followers_url":"https://api.github.com/users/Mathieudewet/followers","following_url":"https://api.github.com/users/Mathieudewet/following{/other_user}","gists_url":"https://api.github.com/users/Mathieudewet/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathieudewet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathieudewet/subscriptions","organizations_url":"https://api.github.com/users/Mathieudewet/orgs","repos_url":"https://api.github.com/users/Mathieudewet/repos","events_url":"https://api.github.com/users/Mathieudewet/events{/privacy}","received_events_url":"https://api.github.com/users/Mathieudewet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mathieudewet/website","description":"The API Platform website","fork":true,"url":"https://api.github.com/repos/Mathieudewet/website","forks_url":"https://api.github.com/repos/Mathieudewet/website/forks","keys_url":"https://api.github.com/repos/Mathieudewet/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mathieudewet/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mathieudewet/website/teams","hooks_url":"https://api.github.com/repos/Mathieudewet/website/hooks","issue_events_url":"https://api.github.com/repos/Mathieudewet/website/issues/events{/number}","events_url":"https://api.github.com/repos/Mathieudewet/website/events","assignees_url":"https://api.github.com/repos/Mathieudewet/website/assignees{/user}","branches_url":"https://api.github.com/repos/Mathieudewet/website/branches{/branch}","tags_url":"https://api.github.com/repos/Mathieudewet/website/tags","blobs_url":"https://api.github.com/repos/Mathieudewet/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mathieudewet/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mathieudewet/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mathieudewet/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mathieudewet/website/statuses/{sha}","languages_url":"https://api.github.com/repos/Mathieudewet/website/languages","stargazers_url":"https://api.github.com/repos/Mathieudewet/website/stargazers","contributors_url":"https://api.github.com/repos/Mathieudewet/website/contributors","subscribers_url":"https://api.github.com/repos/Mathieudewet/website/subscribers","subscription_url":"https://api.github.com/repos/Mathieudewet/website/subscription","commits_url":"https://api.github.com/repos/Mathieudewet/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mathieudewet/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mathieudewet/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mathieudewet/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mathieudewet/website/contents/{+path}","compare_url":"https://api.github.com/repos/Mathieudewet/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mathieudewet/website/merges","archive_url":"https://api.github.com/repos/Mathieudewet/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mathieudewet/website/downloads","issues_url":"https://api.github.com/repos/Mathieudewet/website/issues{/number}","pulls_url":"https://api.github.com/repos/Mathieudewet/website/pulls{/number}","milestones_url":"https://api.github.com/repos/Mathieudewet/website/milestones{/number}","notifications_url":"https://api.github.com/repos/Mathieudewet/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mathieudewet/website/labels{/name}","releases_url":"https://api.github.com/repos/Mathieudewet/website/releases{/id}","deployments_url":"https://api.github.com/repos/Mathieudewet/website/deployments","created_at":"2018-05-18T11:31:19Z","updated_at":"2018-05-18T11:31:21Z","pushed_at":"2018-06-27T09:00:14Z","git_url":"git://github.com/Mathieudewet/website.git","ssh_url":"git@github.com:Mathieudewet/website.git","clone_url":"https://github.com/Mathieudewet/website.git","svn_url":"https://github.com/Mathieudewet/website","homepage":"https://api-platform.com","size":4170,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"api-platform:master","ref":"master","sha":"7a51266388cc843c2806bdb4f2f84abdfff213fa","user":{"login":"api-platform","id":13420081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDgx","avatar_url":"https://avatars3.githubusercontent.com/u/13420081?v=4","gravatar_id":"","url":"https://api.github.com/users/api-platform","html_url":"https://github.com/api-platform","followers_url":"https://api.github.com/users/api-platform/followers","following_url":"https://api.github.com/users/api-platform/following{/other_user}","gists_url":"https://api.github.com/users/api-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/api-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-platform/subscriptions","organizations_url":"https://api.github.com/users/api-platform/orgs","repos_url":"https://api.github.com/users/api-platform/repos","events_url":"https://api.github.com/users/api-platform/events{/privacy}","received_events_url":"https://api.github.com/users/api-platform/received_events","type":"Organization","site_admin":false},"repo":{"id":42137244,"node_id":"MDEwOlJlcG9zaXRvcnk0MjEzNzI0NA==","name":"website","full_name":"api-platform/website","owner":{"login":"api-platform","id":13420081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDgx","avatar_url":"https://avatars3.githubusercontent.com/u/13420081?v=4","gravatar_id":"","url":"https://api.github.com/users/api-platform","html_url":"https://github.com/api-platform","followers_url":"https://api.github.com/users/api-platform/followers","following_url":"https://api.github.com/users/api-platform/following{/other_user}","gists_url":"https://api.github.com/users/api-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/api-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-platform/subscriptions","organizations_url":"https://api.github.com/users/api-platform/orgs","repos_url":"https://api.github.com/users/api-platform/repos","events_url":"https://api.github.com/users/api-platform/events{/privacy}","received_events_url":"https://api.github.com/users/api-platform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/api-platform/website","description":"The API Platform website","fork":false,"url":"https://api.github.com/repos/api-platform/website","forks_url":"https://api.github.com/repos/api-platform/website/forks","keys_url":"https://api.github.com/repos/api-platform/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/api-platform/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/api-platform/website/teams","hooks_url":"https://api.github.com/repos/api-platform/website/hooks","issue_events_url":"https://api.github.com/repos/api-platform/website/issues/events{/number}","events_url":"https://api.github.com/repos/api-platform/website/events","assignees_url":"https://api.github.com/repos/api-platform/website/assignees{/user}","branches_url":"https://api.github.com/repos/api-platform/website/branches{/branch}","tags_url":"https://api.github.com/repos/api-platform/website/tags","blobs_url":"https://api.github.com/repos/api-platform/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/api-platform/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/api-platform/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/api-platform/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/api-platform/website/statuses/{sha}","languages_url":"https://api.github.com/repos/api-platform/website/languages","stargazers_url":"https://api.github.com/repos/api-platform/website/stargazers","contributors_url":"https://api.github.com/repos/api-platform/website/contributors","subscribers_url":"https://api.github.com/repos/api-platform/website/subscribers","subscription_url":"https://api.github.com/repos/api-platform/website/subscription","commits_url":"https://api.github.com/repos/api-platform/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/api-platform/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/api-platform/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/api-platform/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/api-platform/website/contents/{+path}","compare_url":"https://api.github.com/repos/api-platform/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/api-platform/website/merges","archive_url":"https://api.github.com/repos/api-platform/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/api-platform/website/downloads","issues_url":"https://api.github.com/repos/api-platform/website/issues{/number}","pulls_url":"https://api.github.com/repos/api-platform/website/pulls{/number}","milestones_url":"https://api.github.com/repos/api-platform/website/milestones{/number}","notifications_url":"https://api.github.com/repos/api-platform/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/api-platform/website/labels{/name}","releases_url":"https://api.github.com/repos/api-platform/website/releases{/id}","deployments_url":"https://api.github.com/repos/api-platform/website/deployments","created_at":"2015-09-08T20:28:25Z","updated_at":"2018-06-10T23:39:12Z","pushed_at":"2018-06-27T09:00:15Z","git_url":"git://github.com/api-platform/website.git","ssh_url":"git@github.com:api-platform/website.git","clone_url":"https://github.com/api-platform/website.git","svn_url":"https://github.com/api-platform/website","homepage":"https://api-platform.com","size":4068,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":27,"open_issues":4,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/api-platform/website/pulls/42"},"html":{"href":"https://github.com/api-platform/website/pull/42"},"issue":{"href":"https://api.github.com/repos/api-platform/website/issues/42"},"comments":{"href":"https://api.github.com/repos/api-platform/website/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/api-platform/website/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/api-platform/website/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/api-platform/website/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/api-platform/website/statuses/ff1928006421e396e8d7a16a0242f0c195bcfb45"}},"author_association":"NONE"}}
{"actor":{"display_login":"toofff"}}