{"action":"created","comment":{"url":"https://api.github.com/repos/improbable-research/keanu/pulls/comments/231143508","pull_request_review_id":172025071,"id":231143508,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTE0MzUwOA==","diff_hunk":"@@ -0,0 +1,75 @@\n+package io.improbable.keanu.codegen.python;\n+\n+import com.google.gson.Gson;\n+import com.google.gson.reflect.TypeToken;\n+import com.sun.javadoc.*;\n+import com.sun.tools.doclets.standard.Standard;\n+import io.improbable.keanu.annotation.ExportVertexToPythonBindings;\n+\n+import java.io.*;\n+import java.lang.reflect.Type;\n+import java.util.*;\n+\n+public class KeanuProjectDoclet extends Standard {\n+\n+    private static final String DESTINATION_FILE_NAME = \"javadocstrings.json\";\n+    private static final String READ_DESTINATION = \"./build/resources/\";\n+    private static final String WRITE_DESTINATION = \"./codegen/build/resources/\";\n+\n+    public static boolean start(RootDoc root) {\n+\n+        Map<String, DocString> docStrings = new HashMap<>();\n+        ClassDoc[] classes = root.classes();\n+        for (ClassDoc classDoc : classes) {\n+            for (ConstructorDoc constructorDoc : classDoc.constructors()) {\n+                if (constructorDoc.annotations().length != 0) {\n+                    if (isConstructorAnnotated(constructorDoc)) {\n+                        Map<String, String> params = ParamStringProcessor.getNameToCommentMapping(constructorDoc);\n+                        DocString docString = new DocString(constructorDoc.commentText(), params);\n+                        docStrings.put(constructorDoc.qualifiedName(), docString);\n+                    }\n+                }\n+            }\n+        }\n+        writeDocStringsToFile(docStrings);\n+        return true;\n+    }\n+\n+    private static boolean isConstructorAnnotated(ConstructorDoc constructorDoc) {\n+        for (AnnotationDesc an: constructorDoc.annotations()) {\n+            String exportVertexAnnotationName = \"@\" + ExportVertexToPythonBindings.class.getName();\n+            if (an.toString().equals(exportVertexAnnotationName)) {\n+                return true;\n+            }\n+        }\n+        return false;\n+    }\n+\n+    private static void writeDocStringsToFile(Map<String, DocString> docString) {\n+        try {\n+            Gson gson = new Gson();\n+            String json = gson.toJson(docString);\n+            File outputFile = new File(WRITE_DESTINATION + DESTINATION_FILE_NAME);\n+            outputFile.getParentFile().mkdirs();\n+            outputFile.createNewFile(); // if file already exists will do nothing\n+            OutputStream outputStream = new FileOutputStream(WRITE_DESTINATION + DESTINATION_FILE_NAME, false);\n+            System.out.println(\"Writing docstrings\");\n+            outputStream.write(json.getBytes());\n+            System.out.println(\"Finished writing docstrings\");\n+        } catch (IOException e) {\n+            e.printStackTrace();\n+            System.out.println(\"Could not write to file while processing JavaDoc strings\");","path":"codegen/src/main/java/io/improbable/keanu/codegen/python/KeanuProjectDoclet.java","position":61,"original_position":61,"commit_id":"3ab956a7d033e51f7b06f968631119ea2751b1e2","original_commit_id":"3ab956a7d033e51f7b06f968631119ea2751b1e2","user":{"login":"migwellian","id":1508452,"node_id":"MDQ6VXNlcjE1MDg0NTI=","avatar_url":"https://avatars2.githubusercontent.com/u/1508452?v=4","gravatar_id":"","url":"https://api.github.com/users/migwellian","html_url":"https://github.com/migwellian","followers_url":"https://api.github.com/users/migwellian/followers","following_url":"https://api.github.com/users/migwellian/following{/other_user}","gists_url":"https://api.github.com/users/migwellian/gists{/gist_id}","starred_url":"https://api.github.com/users/migwellian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/migwellian/subscriptions","organizations_url":"https://api.github.com/users/migwellian/orgs","repos_url":"https://api.github.com/users/migwellian/repos","events_url":"https://api.github.com/users/migwellian/events{/privacy}","received_events_url":"https://api.github.com/users/migwellian/received_events","type":"User","site_admin":false},"body":"better to use slf4j: `log.error(\"message\", e);`","created_at":"2018-11-06T14:32:01Z","updated_at":"2018-11-06T14:45:52Z","html_url":"https://github.com/improbable-research/keanu/pull/326#discussion_r231143508","pull_request_url":"https://api.github.com/repos/improbable-research/keanu/pulls/326","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/comments/231143508"},"html":{"href":"https://github.com/improbable-research/keanu/pull/326#discussion_r231143508"},"pull_request":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/326"}}},"pull_request":{"url":"https://api.github.com/repos/improbable-research/keanu/pulls/326","id":227915577,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3OTE1NTc3","html_url":"https://github.com/improbable-research/keanu/pull/326","diff_url":"https://github.com/improbable-research/keanu/pull/326.diff","patch_url":"https://github.com/improbable-research/keanu/pull/326.patch","issue_url":"https://api.github.com/repos/improbable-research/keanu/issues/326","number":326,"state":"open","locked":false,"title":"Generate python constructor docs from JavaDoc strings","user":{"login":"CharlieCrisp","id":23122367,"node_id":"MDQ6VXNlcjIzMTIyMzY3","avatar_url":"https://avatars3.githubusercontent.com/u/23122367?v=4","gravatar_id":"","url":"https://api.github.com/users/CharlieCrisp","html_url":"https://github.com/CharlieCrisp","followers_url":"https://api.github.com/users/CharlieCrisp/followers","following_url":"https://api.github.com/users/CharlieCrisp/following{/other_user}","gists_url":"https://api.github.com/users/CharlieCrisp/gists{/gist_id}","starred_url":"https://api.github.com/users/CharlieCrisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CharlieCrisp/subscriptions","organizations_url":"https://api.github.com/users/CharlieCrisp/orgs","repos_url":"https://api.github.com/users/CharlieCrisp/repos","events_url":"https://api.github.com/users/CharlieCrisp/events{/privacy}","received_events_url":"https://api.github.com/users/CharlieCrisp/received_events","type":"User","site_admin":false},"body":"This PR introduces a feature to allow python constructors to pull in JavaDoc strings from their respective Java constructors. \r\nThe workflow currently is as follows:\r\n - run `./gradlew saveJavadocStringsToFile` to generate `javadocstrings.json` file in `/codegen/out` containing all the required javadoc info. \r\n - run `io.improbable.keanu.codegen.python.Runner.main()` to pull in this information and use it in the generated code.\r\n\r\nWhat is not covered: \r\n - Python docs in hand written code\r\n - Actually creation of python docs using e.g. Sphinx\r\n - Any sort of generated python code that isn't a constructor","created_at":"2018-11-02T12:01:26Z","updated_at":"2018-11-06T14:45:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29d5dcf7d2a7aa806c3753e81b1817ee3071b20c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/improbable-research/keanu/pulls/326/commits","review_comments_url":"https://api.github.com/repos/improbable-research/keanu/pulls/326/comments","review_comment_url":"https://api.github.com/repos/improbable-research/keanu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/improbable-research/keanu/issues/326/comments","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/3ab956a7d033e51f7b06f968631119ea2751b1e2","head":{"label":"improbable-research:feature/use-javadoc-in-python-constructors","ref":"feature/use-javadoc-in-python-constructors","sha":"3ab956a7d033e51f7b06f968631119ea2751b1e2","user":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"repo":{"id":128393918,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgzOTM5MTg=","name":"keanu","full_name":"improbable-research/keanu","private":false,"owner":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/improbable-research/keanu","description":"A probabilistic approach from an Improbabilistic company","fork":false,"url":"https://api.github.com/repos/improbable-research/keanu","forks_url":"https://api.github.com/repos/improbable-research/keanu/forks","keys_url":"https://api.github.com/repos/improbable-research/keanu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-research/keanu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-research/keanu/teams","hooks_url":"https://api.github.com/repos/improbable-research/keanu/hooks","issue_events_url":"https://api.github.com/repos/improbable-research/keanu/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-research/keanu/events","assignees_url":"https://api.github.com/repos/improbable-research/keanu/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-research/keanu/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-research/keanu/tags","blobs_url":"https://api.github.com/repos/improbable-research/keanu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-research/keanu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-research/keanu/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-research/keanu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-research/keanu/languages","stargazers_url":"https://api.github.com/repos/improbable-research/keanu/stargazers","contributors_url":"https://api.github.com/repos/improbable-research/keanu/contributors","subscribers_url":"https://api.github.com/repos/improbable-research/keanu/subscribers","subscription_url":"https://api.github.com/repos/improbable-research/keanu/subscription","commits_url":"https://api.github.com/repos/improbable-research/keanu/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-research/keanu/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-research/keanu/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-research/keanu/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-research/keanu/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-research/keanu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-research/keanu/merges","archive_url":"https://api.github.com/repos/improbable-research/keanu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-research/keanu/downloads","issues_url":"https://api.github.com/repos/improbable-research/keanu/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-research/keanu/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-research/keanu/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-research/keanu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-research/keanu/labels{/name}","releases_url":"https://api.github.com/repos/improbable-research/keanu/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-research/keanu/deployments","created_at":"2018-04-06T12:48:36Z","updated_at":"2018-11-05T17:55:47Z","pushed_at":"2018-11-06T12:27:51Z","git_url":"git://github.com/improbable-research/keanu.git","ssh_url":"git@github.com:improbable-research/keanu.git","clone_url":"https://github.com/improbable-research/keanu.git","svn_url":"https://github.com/improbable-research/keanu","homepage":"","size":7997,"stargazers_count":108,"watchers_count":108,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":16,"watchers":108,"default_branch":"develop"}},"base":{"label":"improbable-research:develop","ref":"develop","sha":"40e6e7578fca1a23dc78ef304a3f4c3795fe339a","user":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"repo":{"id":128393918,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgzOTM5MTg=","name":"keanu","full_name":"improbable-research/keanu","private":false,"owner":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/improbable-research/keanu","description":"A probabilistic approach from an Improbabilistic company","fork":false,"url":"https://api.github.com/repos/improbable-research/keanu","forks_url":"https://api.github.com/repos/improbable-research/keanu/forks","keys_url":"https://api.github.com/repos/improbable-research/keanu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-research/keanu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-research/keanu/teams","hooks_url":"https://api.github.com/repos/improbable-research/keanu/hooks","issue_events_url":"https://api.github.com/repos/improbable-research/keanu/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-research/keanu/events","assignees_url":"https://api.github.com/repos/improbable-research/keanu/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-research/keanu/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-research/keanu/tags","blobs_url":"https://api.github.com/repos/improbable-research/keanu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-research/keanu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-research/keanu/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-research/keanu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-research/keanu/languages","stargazers_url":"https://api.github.com/repos/improbable-research/keanu/stargazers","contributors_url":"https://api.github.com/repos/improbable-research/keanu/contributors","subscribers_url":"https://api.github.com/repos/improbable-research/keanu/subscribers","subscription_url":"https://api.github.com/repos/improbable-research/keanu/subscription","commits_url":"https://api.github.com/repos/improbable-research/keanu/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-research/keanu/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-research/keanu/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-research/keanu/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-research/keanu/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-research/keanu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-research/keanu/merges","archive_url":"https://api.github.com/repos/improbable-research/keanu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-research/keanu/downloads","issues_url":"https://api.github.com/repos/improbable-research/keanu/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-research/keanu/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-research/keanu/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-research/keanu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-research/keanu/labels{/name}","releases_url":"https://api.github.com/repos/improbable-research/keanu/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-research/keanu/deployments","created_at":"2018-04-06T12:48:36Z","updated_at":"2018-11-05T17:55:47Z","pushed_at":"2018-11-06T12:27:51Z","git_url":"git://github.com/improbable-research/keanu.git","ssh_url":"git@github.com:improbable-research/keanu.git","clone_url":"https://github.com/improbable-research/keanu.git","svn_url":"https://github.com/improbable-research/keanu","homepage":"","size":7997,"stargazers_count":108,"watchers_count":108,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":16,"watchers":108,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/326"},"html":{"href":"https://github.com/improbable-research/keanu/pull/326"},"issue":{"href":"https://api.github.com/repos/improbable-research/keanu/issues/326"},"comments":{"href":"https://api.github.com/repos/improbable-research/keanu/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/326/comments"},"review_comment":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/326/commits"},"statuses":{"href":"https://api.github.com/repos/improbable-research/keanu/statuses/3ab956a7d033e51f7b06f968631119ea2751b1e2"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"migwellian"}}