{"action":"opened","number":49,"pull_request":{"url":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49","id":285018640,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjg1MDE4NjQw","html_url":"https://github.com/mdn/stumptown-experiment/pull/49","diff_url":"https://github.com/mdn/stumptown-experiment/pull/49.diff","patch_url":"https://github.com/mdn/stumptown-experiment/pull/49.patch","issue_url":"https://api.github.com/repos/mdn/stumptown-experiment/issues/49","number":49,"state":"open","locked":false,"title":"Enforce uniqueness of example titles","user":{"login":"peterbe","id":26739,"node_id":"MDQ6VXNlcjI2NzM5","avatar_url":"https://avatars2.githubusercontent.com/u/26739?v=4","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"body":"Fixes #47\r\n\r\nFirst all, to test this I messed with the `.md` files temporarily. Looked like this:\r\n<img width=\"339\" alt=\"Screen Shot 2019-06-04 at 10 54 47 AM\" src=\"https://user-images.githubusercontent.com/26739/58889760-6e596400-86b7-11e9-98d1-2e03426e2e33.png\">\r\n\r\nNow you get this:\r\n```\r\n▶ npm run build-json video\r\n\r\n> stump@0.1.0 build-json /Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment\r\n> node scripts/build-json/build-json.js \"video\"\r\n\r\n/Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment/scripts/build-json/compose-examples.js:58\r\n        throw new Error(\r\n        ^\r\n\r\nError: Every example's description title must be unique ([\"generic title\"])\r\n    at Object.package (/Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment/scripts/build-json/compose-examples.js:58:15)\r\n    at Object.buildPageJSON (/Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment/scripts/build-json/build-page-json.js:60:33)\r\n    at buildJSON (/Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment/scripts/build-json/build-json.js:37:29)\r\n    at Object.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/stumptown-experiment/scripts/build-json/build-json.js:42:14)\r\n    at Module._compile (internal/modules/cjs/loader.js:774:30)\r\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)\r\n    at Module.load (internal/modules/cjs/loader.js:641:32)\r\n    at Function.Module._load (internal/modules/cjs/loader.js:556:12)\r\n    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)\r\n    at internal/main/run_main_module.js:17:11\r\n```\r\n\r\nThere is a more important discussion to be had. We *could* **not** do this and instead put code like this in some other place. Instead of doing it in `compose-example.js` it could be done as an \"extension\" to `build-json.js`. \r\n\r\nFor example, the `buildPageJSON` function (in `build-page-json.js`) has this idea of putting together an Object and then writing that to disk. Within the function it does some checks (arguably not related to the actual content much) and then returns a different error other than 0. For example, in [`buildPageJSON()`](https://github.com/mdn/stumptown-experiment/blob/9b706592a12a1c79f6a6e1ced9e9e7d134f3d0c3/scripts/build-json/build-page-json.js#L60)\r\nit does this:\r\n```javascript\r\nelement.examples = examples.package(examplesPaths);\r\n```\r\nWe could change that to:\r\n```javascript\r\nelement.examples = examples.package(examplesPaths);\r\nvalidateExamples(element.examples);\r\n```\r\n\r\nThe same effort needs to be done but it's a matter of code layout where we put that business logic. I think I prefer to do that kinda stuff near and close to the code that generates and raise exceptions as early as possible. After all, if you do throw exceptions you can still rewrite the surrounding tooling to work like this:\r\n\r\n```javascript\r\nfor (let item of items) {\r\n    try {\r\n        errors += buildPage.buildPageJSON(item);\r\n    } catch(exc) {\r\n        console.warn(`Failed to build ${item}`);\r\n       errors += 1;\r\n    }\r\n}\r\n```","created_at":"2019-06-04T15:07:18Z","updated_at":"2019-06-04T15:07:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[{"login":"wbamberg","id":432915,"node_id":"MDQ6VXNlcjQzMjkxNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/432915?v=4","gravatar_id":"","url":"https://api.github.com/users/wbamberg","html_url":"https://github.com/wbamberg","followers_url":"https://api.github.com/users/wbamberg/followers","following_url":"https://api.github.com/users/wbamberg/following{/other_user}","gists_url":"https://api.github.com/users/wbamberg/gists{/gist_id}","starred_url":"https://api.github.com/users/wbamberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wbamberg/subscriptions","organizations_url":"https://api.github.com/users/wbamberg/orgs","repos_url":"https://api.github.com/users/wbamberg/repos","events_url":"https://api.github.com/users/wbamberg/events{/privacy}","received_events_url":"https://api.github.com/users/wbamberg/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49/commits","review_comments_url":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49/comments","review_comment_url":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mdn/stumptown-experiment/issues/49/comments","statuses_url":"https://api.github.com/repos/mdn/stumptown-experiment/statuses/6a76dc5fb343e7f101c2e7b193c6b7e346cdfc93","head":{"label":"peterbe:47-enforce-uniqueness-of-example-titles","ref":"47-enforce-uniqueness-of-example-titles","sha":"6a76dc5fb343e7f101c2e7b193c6b7e346cdfc93","user":{"login":"peterbe","id":26739,"node_id":"MDQ6VXNlcjI2NzM5","avatar_url":"https://avatars2.githubusercontent.com/u/26739?v=4","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"repo":{"id":185475248,"node_id":"MDEwOlJlcG9zaXRvcnkxODU0NzUyNDg=","name":"stumptown-experiment","full_name":"peterbe/stumptown-experiment","private":false,"owner":{"login":"peterbe","id":26739,"node_id":"MDQ6VXNlcjI2NzM5","avatar_url":"https://avatars2.githubusercontent.com/u/26739?v=4","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"html_url":"https://github.com/peterbe/stumptown-experiment","description":null,"fork":true,"url":"https://api.github.com/repos/peterbe/stumptown-experiment","forks_url":"https://api.github.com/repos/peterbe/stumptown-experiment/forks","keys_url":"https://api.github.com/repos/peterbe/stumptown-experiment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peterbe/stumptown-experiment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peterbe/stumptown-experiment/teams","hooks_url":"https://api.github.com/repos/peterbe/stumptown-experiment/hooks","issue_events_url":"https://api.github.com/repos/peterbe/stumptown-experiment/issues/events{/number}","events_url":"https://api.github.com/repos/peterbe/stumptown-experiment/events","assignees_url":"https://api.github.com/repos/peterbe/stumptown-experiment/assignees{/user}","branches_url":"https://api.github.com/repos/peterbe/stumptown-experiment/branches{/branch}","tags_url":"https://api.github.com/repos/peterbe/stumptown-experiment/tags","blobs_url":"https://api.github.com/repos/peterbe/stumptown-experiment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peterbe/stumptown-experiment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peterbe/stumptown-experiment/git/refs{/sha}","trees_url":"https://api.github.com/repos/peterbe/stumptown-experiment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peterbe/stumptown-experiment/statuses/{sha}","languages_url":"https://api.github.com/repos/peterbe/stumptown-experiment/languages","stargazers_url":"https://api.github.com/repos/peterbe/stumptown-experiment/stargazers","contributors_url":"https://api.github.com/repos/peterbe/stumptown-experiment/contributors","subscribers_url":"https://api.github.com/repos/peterbe/stumptown-experiment/subscribers","subscription_url":"https://api.github.com/repos/peterbe/stumptown-experiment/subscription","commits_url":"https://api.github.com/repos/peterbe/stumptown-experiment/commits{/sha}","git_commits_url":"https://api.github.com/repos/peterbe/stumptown-experiment/git/commits{/sha}","comments_url":"https://api.github.com/repos/peterbe/stumptown-experiment/comments{/number}","issue_comment_url":"https://api.github.com/repos/peterbe/stumptown-experiment/issues/comments{/number}","contents_url":"https://api.github.com/repos/peterbe/stumptown-experiment/contents/{+path}","compare_url":"https://api.github.com/repos/peterbe/stumptown-experiment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peterbe/stumptown-experiment/merges","archive_url":"https://api.github.com/repos/peterbe/stumptown-experiment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peterbe/stumptown-experiment/downloads","issues_url":"https://api.github.com/repos/peterbe/stumptown-experiment/issues{/number}","pulls_url":"https://api.github.com/repos/peterbe/stumptown-experiment/pulls{/number}","milestones_url":"https://api.github.com/repos/peterbe/stumptown-experiment/milestones{/number}","notifications_url":"https://api.github.com/repos/peterbe/stumptown-experiment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peterbe/stumptown-experiment/labels{/name}","releases_url":"https://api.github.com/repos/peterbe/stumptown-experiment/releases{/id}","deployments_url":"https://api.github.com/repos/peterbe/stumptown-experiment/deployments","created_at":"2019-05-07T20:44:25Z","updated_at":"2019-05-07T20:44:28Z","pushed_at":"2019-06-04T14:55:47Z","git_url":"git://github.com/peterbe/stumptown-experiment.git","ssh_url":"git@github.com:peterbe/stumptown-experiment.git","clone_url":"https://github.com/peterbe/stumptown-experiment.git","svn_url":"https://github.com/peterbe/stumptown-experiment","homepage":null,"size":429,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mdn:master","ref":"master","sha":"9b706592a12a1c79f6a6e1ced9e9e7d134f3d0c3","user":{"login":"mdn","id":7565578,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1NjU1Nzg=","avatar_url":"https://avatars0.githubusercontent.com/u/7565578?v=4","gravatar_id":"","url":"https://api.github.com/users/mdn","html_url":"https://github.com/mdn","followers_url":"https://api.github.com/users/mdn/followers","following_url":"https://api.github.com/users/mdn/following{/other_user}","gists_url":"https://api.github.com/users/mdn/gists{/gist_id}","starred_url":"https://api.github.com/users/mdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdn/subscriptions","organizations_url":"https://api.github.com/users/mdn/orgs","repos_url":"https://api.github.com/users/mdn/repos","events_url":"https://api.github.com/users/mdn/events{/privacy}","received_events_url":"https://api.github.com/users/mdn/received_events","type":"Organization","site_admin":false},"repo":{"id":157610072,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc2MTAwNzI=","name":"stumptown-experiment","full_name":"mdn/stumptown-experiment","private":false,"owner":{"login":"mdn","id":7565578,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1NjU1Nzg=","avatar_url":"https://avatars0.githubusercontent.com/u/7565578?v=4","gravatar_id":"","url":"https://api.github.com/users/mdn","html_url":"https://github.com/mdn","followers_url":"https://api.github.com/users/mdn/followers","following_url":"https://api.github.com/users/mdn/following{/other_user}","gists_url":"https://api.github.com/users/mdn/gists{/gist_id}","starred_url":"https://api.github.com/users/mdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdn/subscriptions","organizations_url":"https://api.github.com/users/mdn/orgs","repos_url":"https://api.github.com/users/mdn/repos","events_url":"https://api.github.com/users/mdn/events{/privacy}","received_events_url":"https://api.github.com/users/mdn/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mdn/stumptown-experiment","description":null,"fork":false,"url":"https://api.github.com/repos/mdn/stumptown-experiment","forks_url":"https://api.github.com/repos/mdn/stumptown-experiment/forks","keys_url":"https://api.github.com/repos/mdn/stumptown-experiment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdn/stumptown-experiment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdn/stumptown-experiment/teams","hooks_url":"https://api.github.com/repos/mdn/stumptown-experiment/hooks","issue_events_url":"https://api.github.com/repos/mdn/stumptown-experiment/issues/events{/number}","events_url":"https://api.github.com/repos/mdn/stumptown-experiment/events","assignees_url":"https://api.github.com/repos/mdn/stumptown-experiment/assignees{/user}","branches_url":"https://api.github.com/repos/mdn/stumptown-experiment/branches{/branch}","tags_url":"https://api.github.com/repos/mdn/stumptown-experiment/tags","blobs_url":"https://api.github.com/repos/mdn/stumptown-experiment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdn/stumptown-experiment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdn/stumptown-experiment/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdn/stumptown-experiment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdn/stumptown-experiment/statuses/{sha}","languages_url":"https://api.github.com/repos/mdn/stumptown-experiment/languages","stargazers_url":"https://api.github.com/repos/mdn/stumptown-experiment/stargazers","contributors_url":"https://api.github.com/repos/mdn/stumptown-experiment/contributors","subscribers_url":"https://api.github.com/repos/mdn/stumptown-experiment/subscribers","subscription_url":"https://api.github.com/repos/mdn/stumptown-experiment/subscription","commits_url":"https://api.github.com/repos/mdn/stumptown-experiment/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdn/stumptown-experiment/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdn/stumptown-experiment/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdn/stumptown-experiment/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdn/stumptown-experiment/contents/{+path}","compare_url":"https://api.github.com/repos/mdn/stumptown-experiment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdn/stumptown-experiment/merges","archive_url":"https://api.github.com/repos/mdn/stumptown-experiment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdn/stumptown-experiment/downloads","issues_url":"https://api.github.com/repos/mdn/stumptown-experiment/issues{/number}","pulls_url":"https://api.github.com/repos/mdn/stumptown-experiment/pulls{/number}","milestones_url":"https://api.github.com/repos/mdn/stumptown-experiment/milestones{/number}","notifications_url":"https://api.github.com/repos/mdn/stumptown-experiment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdn/stumptown-experiment/labels{/name}","releases_url":"https://api.github.com/repos/mdn/stumptown-experiment/releases{/id}","deployments_url":"https://api.github.com/repos/mdn/stumptown-experiment/deployments","created_at":"2018-11-14T20:57:54Z","updated_at":"2019-06-04T12:23:08Z","pushed_at":"2019-06-04T12:29:10Z","git_url":"git://github.com/mdn/stumptown-experiment.git","ssh_url":"git@github.com:mdn/stumptown-experiment.git","clone_url":"https://github.com/mdn/stumptown-experiment.git","svn_url":"https://github.com/mdn/stumptown-experiment","homepage":null,"size":412,"stargazers_count":4,"watchers_count":4,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":22,"license":null,"forks":6,"open_issues":22,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49"},"html":{"href":"https://github.com/mdn/stumptown-experiment/pull/49"},"issue":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/issues/49"},"comments":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/mdn/stumptown-experiment/statuses/6a76dc5fb343e7f101c2e7b193c6b7e346cdfc93"}},"author_association":"COLLABORATOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":19,"deletions":1,"changed_files":1}}
{"actor":{"display_login":"peterbe"}}