{"action":"created","comment":{"url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/comments/42378144","id":42378144,"diff_hunk":"@@ -304,3 +309,123 @@ def to_thebe_html(path, env_vars, fmt, cwd, template_fn):\n     if stderr:\n         raise RuntimeError('nbconvert wrote to stderr: {}'.format(stderr))\n     return stdout\n+\n+def get_references(abs_nb_path, version):\n+    '''\n+    Retrieves the raw references to files, folders, and exclusions\n+    from a notebook's markdown cell comments.\n+    '''\n+    notebook = nbformat.read(abs_nb_path, version)\n+    referenced_list = []\n+    for cell in notebook.cells:\n+        references = _get_references(cell)\n+        if references:\n+            referenced_list = referenced_list + references\n+    return referenced_list\n+\n+def get_referenced_files(abs_nb_path, version):\n+    '''\n+    Retrieves the full list of files referenced by a notebook's\n+    markdown cell comments, as relative paths. Temporarily changes\n+    the current working directory when called.\n+    '''\n+    expanded = _expand_references(os.path.dirname(abs_nb_path), get_references(abs_nb_path, version))\n+    return expanded\n+\n+def _get_references(cell):\n+    '''\n+    Retrieves the list of references from a cell, according to\n+    an expected way of identifying and separating them.\n+    '''\n+    referenced = None\n+    # invisible after execution: unrendered HTML comment\n+    if cell.get('cell_type').startswith('markdown') and cell.get('source').startswith('<!--associate:'):\n+        referenced = []\n+        lines = cell.get('source')[14:].splitlines()\n+        for line in lines:\n+            if line.startswith('-->'):\n+                break\n+            # Trying to go out of the current directory leads to\n+            # trouble when deploying\n+            if line.find('../') < 0 and not line.startswith('#'):\n+                referenced.append(line)\n+    # visible after execution: rendered as a code element within a pre element\n+    elif cell.get('cell_type').startswith('markdown') and cell.get('source').find('```') >= 0:","path":"urth/dashboard/converter/__init__.py","position":73,"original_position":73,"commit_id":"3ab5e74cffa8f8e0a840699a6b0bf4b1b68ba062","original_commit_id":"3ab5e74cffa8f8e0a840699a6b0bf4b1b68ba062","user":{"login":"parente","id":153745,"avatar_url":"https://avatars.githubusercontent.com/u/153745?v=3","gravatar_id":"","url":"https://api.github.com/users/parente","html_url":"https://github.com/parente","followers_url":"https://api.github.com/users/parente/followers","following_url":"https://api.github.com/users/parente/following{/other_user}","gists_url":"https://api.github.com/users/parente/gists{/gist_id}","starred_url":"https://api.github.com/users/parente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parente/subscriptions","organizations_url":"https://api.github.com/users/parente/orgs","repos_url":"https://api.github.com/users/parente/repos","events_url":"https://api.github.com/users/parente/events{/privacy}","received_events_url":"https://api.github.com/users/parente/received_events","type":"User","site_admin":false},"body":"Is there a reason the comment syntax has a prefix but not the triple back tick (fenced code block)? Any concerns about parsing all fenced code blocks and checking for existence of files on disk. For example, what if I have a fenced block I'm using to list a set of file names purely for documentation purposes, not to have them packed up with the notebook?","created_at":"2015-10-19T14:34:50Z","updated_at":"2015-10-19T14:34:50Z","html_url":"https://github.com/jupyter-incubator/dashboards/pull/32#discussion_r42378144","pull_request_url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/comments/42378144"},"html":{"href":"https://github.com/jupyter-incubator/dashboards/pull/32#discussion_r42378144"},"pull_request":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32","id":47549690,"html_url":"https://github.com/jupyter-incubator/dashboards/pull/32","diff_url":"https://github.com/jupyter-incubator/dashboards/pull/32.diff","patch_url":"https://github.com/jupyter-incubator/dashboards/pull/32.patch","issue_url":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/32","number":32,"state":"open","locked":false,"title":"[WIP] [issue 11] include local files when downloading and deploying","user":{"login":"nitind","id":2684153,"avatar_url":"https://avatars.githubusercontent.com/u/2684153?v=3","gravatar_id":"","url":"https://api.github.com/users/nitind","html_url":"https://github.com/nitind","followers_url":"https://api.github.com/users/nitind/followers","following_url":"https://api.github.com/users/nitind/following{/other_user}","gists_url":"https://api.github.com/users/nitind/gists{/gist_id}","starred_url":"https://api.github.com/users/nitind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitind/subscriptions","organizations_url":"https://api.github.com/users/nitind/orgs","repos_url":"https://api.github.com/users/nitind/repos","events_url":"https://api.github.com/users/nitind/events{/privacy}","received_events_url":"https://api.github.com/users/nitind/received_events","type":"User","site_admin":false},"body":"Automatically downloads and deploys files tied to a notebook.\r\n\r\nUses Markdown cell HTML comments starting with '<!--associate:'\r\non its own line and .gitignore-like filespec patterns on following\r\nlines. For now.","created_at":"2015-10-13T15:36:41Z","updated_at":"2015-10-19T14:34:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"218cf63d248cbf759a083d5e8b7b07c047e7df58","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32/commits","review_comments_url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32/comments","review_comment_url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/32/comments","statuses_url":"https://api.github.com/repos/jupyter-incubator/dashboards/statuses/3ab5e74cffa8f8e0a840699a6b0bf4b1b68ba062","head":{"label":"nitind:include-local-files","ref":"include-local-files","sha":"3ab5e74cffa8f8e0a840699a6b0bf4b1b68ba062","user":{"login":"nitind","id":2684153,"avatar_url":"https://avatars.githubusercontent.com/u/2684153?v=3","gravatar_id":"","url":"https://api.github.com/users/nitind","html_url":"https://github.com/nitind","followers_url":"https://api.github.com/users/nitind/followers","following_url":"https://api.github.com/users/nitind/following{/other_user}","gists_url":"https://api.github.com/users/nitind/gists{/gist_id}","starred_url":"https://api.github.com/users/nitind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitind/subscriptions","organizations_url":"https://api.github.com/users/nitind/orgs","repos_url":"https://api.github.com/users/nitind/repos","events_url":"https://api.github.com/users/nitind/events{/privacy}","received_events_url":"https://api.github.com/users/nitind/received_events","type":"User","site_admin":false},"repo":{"id":43332877,"name":"dashboards","full_name":"nitind/dashboards","owner":{"login":"nitind","id":2684153,"avatar_url":"https://avatars.githubusercontent.com/u/2684153?v=3","gravatar_id":"","url":"https://api.github.com/users/nitind","html_url":"https://github.com/nitind","followers_url":"https://api.github.com/users/nitind/followers","following_url":"https://api.github.com/users/nitind/following{/other_user}","gists_url":"https://api.github.com/users/nitind/gists{/gist_id}","starred_url":"https://api.github.com/users/nitind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitind/subscriptions","organizations_url":"https://api.github.com/users/nitind/orgs","repos_url":"https://api.github.com/users/nitind/repos","events_url":"https://api.github.com/users/nitind/events{/privacy}","received_events_url":"https://api.github.com/users/nitind/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nitind/dashboards","description":"Jupyter Dynamic Dashboards from Notebooks","fork":true,"url":"https://api.github.com/repos/nitind/dashboards","forks_url":"https://api.github.com/repos/nitind/dashboards/forks","keys_url":"https://api.github.com/repos/nitind/dashboards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nitind/dashboards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nitind/dashboards/teams","hooks_url":"https://api.github.com/repos/nitind/dashboards/hooks","issue_events_url":"https://api.github.com/repos/nitind/dashboards/issues/events{/number}","events_url":"https://api.github.com/repos/nitind/dashboards/events","assignees_url":"https://api.github.com/repos/nitind/dashboards/assignees{/user}","branches_url":"https://api.github.com/repos/nitind/dashboards/branches{/branch}","tags_url":"https://api.github.com/repos/nitind/dashboards/tags","blobs_url":"https://api.github.com/repos/nitind/dashboards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nitind/dashboards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nitind/dashboards/git/refs{/sha}","trees_url":"https://api.github.com/repos/nitind/dashboards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nitind/dashboards/statuses/{sha}","languages_url":"https://api.github.com/repos/nitind/dashboards/languages","stargazers_url":"https://api.github.com/repos/nitind/dashboards/stargazers","contributors_url":"https://api.github.com/repos/nitind/dashboards/contributors","subscribers_url":"https://api.github.com/repos/nitind/dashboards/subscribers","subscription_url":"https://api.github.com/repos/nitind/dashboards/subscription","commits_url":"https://api.github.com/repos/nitind/dashboards/commits{/sha}","git_commits_url":"https://api.github.com/repos/nitind/dashboards/git/commits{/sha}","comments_url":"https://api.github.com/repos/nitind/dashboards/comments{/number}","issue_comment_url":"https://api.github.com/repos/nitind/dashboards/issues/comments{/number}","contents_url":"https://api.github.com/repos/nitind/dashboards/contents/{+path}","compare_url":"https://api.github.com/repos/nitind/dashboards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nitind/dashboards/merges","archive_url":"https://api.github.com/repos/nitind/dashboards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nitind/dashboards/downloads","issues_url":"https://api.github.com/repos/nitind/dashboards/issues{/number}","pulls_url":"https://api.github.com/repos/nitind/dashboards/pulls{/number}","milestones_url":"https://api.github.com/repos/nitind/dashboards/milestones{/number}","notifications_url":"https://api.github.com/repos/nitind/dashboards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nitind/dashboards/labels{/name}","releases_url":"https://api.github.com/repos/nitind/dashboards/releases{/id}","created_at":"2015-09-28T23:28:54Z","updated_at":"2015-09-28T23:28:55Z","pushed_at":"2015-10-16T16:16:01Z","git_url":"git://github.com/nitind/dashboards.git","ssh_url":"git@github.com:nitind/dashboards.git","clone_url":"https://github.com/nitind/dashboards.git","svn_url":"https://github.com/nitind/dashboards","homepage":null,"size":7009,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"jupyter-incubator:master","ref":"master","sha":"bcdd512502f383c219cfa77ae341e8312431c32c","user":{"login":"jupyter-incubator","id":14002361,"avatar_url":"https://avatars.githubusercontent.com/u/14002361?v=3","gravatar_id":"","url":"https://api.github.com/users/jupyter-incubator","html_url":"https://github.com/jupyter-incubator","followers_url":"https://api.github.com/users/jupyter-incubator/followers","following_url":"https://api.github.com/users/jupyter-incubator/following{/other_user}","gists_url":"https://api.github.com/users/jupyter-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyter-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyter-incubator/subscriptions","organizations_url":"https://api.github.com/users/jupyter-incubator/orgs","repos_url":"https://api.github.com/users/jupyter-incubator/repos","events_url":"https://api.github.com/users/jupyter-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/jupyter-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":42875798,"name":"dashboards","full_name":"jupyter-incubator/dashboards","owner":{"login":"jupyter-incubator","id":14002361,"avatar_url":"https://avatars.githubusercontent.com/u/14002361?v=3","gravatar_id":"","url":"https://api.github.com/users/jupyter-incubator","html_url":"https://github.com/jupyter-incubator","followers_url":"https://api.github.com/users/jupyter-incubator/followers","following_url":"https://api.github.com/users/jupyter-incubator/following{/other_user}","gists_url":"https://api.github.com/users/jupyter-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyter-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyter-incubator/subscriptions","organizations_url":"https://api.github.com/users/jupyter-incubator/orgs","repos_url":"https://api.github.com/users/jupyter-incubator/repos","events_url":"https://api.github.com/users/jupyter-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/jupyter-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jupyter-incubator/dashboards","description":"Jupyter Dynamic Dashboards from Notebooks","fork":false,"url":"https://api.github.com/repos/jupyter-incubator/dashboards","forks_url":"https://api.github.com/repos/jupyter-incubator/dashboards/forks","keys_url":"https://api.github.com/repos/jupyter-incubator/dashboards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jupyter-incubator/dashboards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jupyter-incubator/dashboards/teams","hooks_url":"https://api.github.com/repos/jupyter-incubator/dashboards/hooks","issue_events_url":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/events{/number}","events_url":"https://api.github.com/repos/jupyter-incubator/dashboards/events","assignees_url":"https://api.github.com/repos/jupyter-incubator/dashboards/assignees{/user}","branches_url":"https://api.github.com/repos/jupyter-incubator/dashboards/branches{/branch}","tags_url":"https://api.github.com/repos/jupyter-incubator/dashboards/tags","blobs_url":"https://api.github.com/repos/jupyter-incubator/dashboards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jupyter-incubator/dashboards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jupyter-incubator/dashboards/git/refs{/sha}","trees_url":"https://api.github.com/repos/jupyter-incubator/dashboards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jupyter-incubator/dashboards/statuses/{sha}","languages_url":"https://api.github.com/repos/jupyter-incubator/dashboards/languages","stargazers_url":"https://api.github.com/repos/jupyter-incubator/dashboards/stargazers","contributors_url":"https://api.github.com/repos/jupyter-incubator/dashboards/contributors","subscribers_url":"https://api.github.com/repos/jupyter-incubator/dashboards/subscribers","subscription_url":"https://api.github.com/repos/jupyter-incubator/dashboards/subscription","commits_url":"https://api.github.com/repos/jupyter-incubator/dashboards/commits{/sha}","git_commits_url":"https://api.github.com/repos/jupyter-incubator/dashboards/git/commits{/sha}","comments_url":"https://api.github.com/repos/jupyter-incubator/dashboards/comments{/number}","issue_comment_url":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/comments{/number}","contents_url":"https://api.github.com/repos/jupyter-incubator/dashboards/contents/{+path}","compare_url":"https://api.github.com/repos/jupyter-incubator/dashboards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jupyter-incubator/dashboards/merges","archive_url":"https://api.github.com/repos/jupyter-incubator/dashboards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jupyter-incubator/dashboards/downloads","issues_url":"https://api.github.com/repos/jupyter-incubator/dashboards/issues{/number}","pulls_url":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls{/number}","milestones_url":"https://api.github.com/repos/jupyter-incubator/dashboards/milestones{/number}","notifications_url":"https://api.github.com/repos/jupyter-incubator/dashboards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jupyter-incubator/dashboards/labels{/name}","releases_url":"https://api.github.com/repos/jupyter-incubator/dashboards/releases{/id}","created_at":"2015-09-21T15:39:29Z","updated_at":"2015-10-16T01:08:43Z","pushed_at":"2015-10-16T16:16:01Z","git_url":"git://github.com/jupyter-incubator/dashboards.git","ssh_url":"git@github.com:jupyter-incubator/dashboards.git","clone_url":"https://github.com/jupyter-incubator/dashboards.git","svn_url":"https://github.com/jupyter-incubator/dashboards","homepage":null,"size":7156,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":16,"forks":5,"open_issues":16,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32"},"html":{"href":"https://github.com/jupyter-incubator/dashboards/pull/32"},"issue":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/32"},"comments":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/jupyter-incubator/dashboards/statuses/3ab5e74cffa8f8e0a840699a6b0bf4b1b68ba062"}}}}