{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/comments/34319242","id":34319242,"diff_hunk":"@@ -33,22 +52,73 @@ class Puppet4xFunctionHandler < YARD::Handlers::Ruby::Base\n     # Then, traverse the children of the parameters, storing each identifier\n     # in the list of method arguments.\n     obj = MethodObject.new(function_namespace, name) do |o|\n+    end\n+\n+    # overload_signatures is a list of lists of tuples or empty:\n+    # overload_signatures = [\n+    #   [ # First function dispatch arguments\n+    #     # argument name, argument type\n+    #     ['arg0', 'Variant[String,Array[String]]'\n+    #     ['arg1', 'Optional[Type]']\n+    #   ],\n+    #   [ # Second function dispatch arguments\n+    #     ['arg0', 'Variant[String,Array[String]]'\n+    #     ['arg1', 'Optional[Type]']\n+    #     ['arg2', 'Any']\n+    #   ]\n+    # ]\n+    overload_signatures = []\n+    statement.traverse do |node|\n+      # Find all of the dispatch methods\n+      if node.type == :ident and node.source == 'dispatch'\n+        command = node.parent\n+        do_block = command.jump :do_block\n+        # If the command doesn't have a do_block we can't extract type info\n+        if do_block == command\n+          next\n+        end\n+        # Iterate through each of the children of the do block and build\n+        # tuples of parameter names and parameter type signatures\n+        do_block.children.first.children.each do |child|\n+          overload_signatures <<= [extract_type_from_command(child)]\n+        end\n+      end\n+    end\n+\n+    # If the overload_signatures list is empty because we couldn't find any\n+    # dispatch blocks, then there must be one function named the same as the\n+    # name of the function being created.\n+    if overload_signatures.length == 0\n       statement.traverse do |node|\n-        if node.type == :params\n-          node.traverse do |params|\n-            if params.type == :ident\n-              # FIXME: Replace nil with parameter types\n-              method_arguments << [params[0], nil]\n+        # Find the function definition with the same name as the puppet\n+        # function being created.\n+        if (node.type == :def and node.children.first.type == :ident and\n+            node.children.first.source == obj.name.to_s)\n+          signature = []\n+          # Find its parameters. If they don't exist, fine\n+          params = node.jump :params\n+          break if params == node\n+          params.traverse do |param|\n+            if param.type == :ident\n+              # The parameters of Puppet functions with no defined dispatch are\n+              # as though they are Any type.\n+              signature << [param[0], 'Any']\n             end\n           end\n-\n+          overload_signatures <<= signature\n           # Now that the parameters have been found, break out of the traversal\n           break\n         end\n       end\n     end\n \n-    obj.parameters = method_arguments\n+    # Preserve this type information. We'll need it later when we look\n+    # at the docstring.\n+    obj.type_info = overload_signatures\n+\n+    # The yard docstring parser expects a list of lists, not a list of lists of\n+    # lists.","path":"lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_4x_function_handler.rb","position":102,"original_position":102,"commit_id":"64dd545318180b3c41538499599ffcdb0ab309f5","original_commit_id":"64dd545318180b3c41538499599ffcdb0ab309f5","user":{"login":"hlindberg","id":563066,"avatar_url":"https://avatars.githubusercontent.com/u/563066?v=3","gravatar_id":"","url":"https://api.github.com/users/hlindberg","html_url":"https://github.com/hlindberg","followers_url":"https://api.github.com/users/hlindberg/followers","following_url":"https://api.github.com/users/hlindberg/following{/other_user}","gists_url":"https://api.github.com/users/hlindberg/gists{/gist_id}","starred_url":"https://api.github.com/users/hlindberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlindberg/subscriptions","organizations_url":"https://api.github.com/users/hlindberg/orgs","repos_url":"https://api.github.com/users/hlindberg/repos","events_url":"https://api.github.com/users/hlindberg/events{/privacy}","received_events_url":"https://api.github.com/users/hlindberg/received_events","type":"User","site_admin":false},"body":"(picky) - in Ruby \"list\" is referred to as \"array\"","created_at":"2015-07-10T00:32:15Z","updated_at":"2015-07-10T00:32:15Z","html_url":"https://github.com/puppetlabs/puppetlabs-strings/pull/33#discussion_r34319242","pull_request_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/comments/34319242"},"html":{"href":"https://github.com/puppetlabs/puppetlabs-strings/pull/33#discussion_r34319242"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33","id":39614660,"html_url":"https://github.com/puppetlabs/puppetlabs-strings/pull/33","diff_url":"https://github.com/puppetlabs/puppetlabs-strings/pull/33.diff","patch_url":"https://github.com/puppetlabs/puppetlabs-strings/pull/33.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/33","number":33,"state":"open","locked":false,"title":"Dispatch params/pdoc 37","user":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"body":"@hkenney ","created_at":"2015-07-09T18:41:39Z","updated_at":"2015-07-10T00:32:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"584ec80011106f15045e346edf7670ba1598eea2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/33/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/statuses/64dd545318180b3c41538499599ffcdb0ab309f5","head":{"label":"iankronquist:dispatch-params/PDOC-37","ref":"dispatch-params/PDOC-37","sha":"64dd545318180b3c41538499599ffcdb0ab309f5","user":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"repo":{"id":37931654,"name":"puppetlabs-strings","full_name":"iankronquist/puppetlabs-strings","owner":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iankronquist/puppetlabs-strings","description":"The next generation puppet documentation extraction and presentation tool","fork":true,"url":"https://api.github.com/repos/iankronquist/puppetlabs-strings","forks_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/forks","keys_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/teams","hooks_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/hooks","issue_events_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/issues/events{/number}","events_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/events","assignees_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/assignees{/user}","branches_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/branches{/branch}","tags_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/tags","blobs_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/git/refs{/sha}","trees_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/statuses/{sha}","languages_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/languages","stargazers_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/stargazers","contributors_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/contributors","subscribers_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/subscribers","subscription_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/subscription","commits_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/commits{/sha}","git_commits_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/git/commits{/sha}","comments_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/comments{/number}","issue_comment_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/issues/comments{/number}","contents_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/contents/{+path}","compare_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/merges","archive_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/downloads","issues_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/issues{/number}","pulls_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/pulls{/number}","milestones_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/milestones{/number}","notifications_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/labels{/name}","releases_url":"https://api.github.com/repos/iankronquist/puppetlabs-strings/releases{/id}","created_at":"2015-06-23T16:45:39Z","updated_at":"2015-06-23T16:45:40Z","pushed_at":"2015-07-08T23:24:50Z","git_url":"git://github.com/iankronquist/puppetlabs-strings.git","ssh_url":"git@github.com:iankronquist/puppetlabs-strings.git","clone_url":"https://github.com/iankronquist/puppetlabs-strings.git","svn_url":"https://github.com/iankronquist/puppetlabs-strings","homepage":null,"size":299,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"puppetlabs:master","ref":"master","sha":"c8fbe3c20fb5c7b0eff8a2e4266251ce166d7ee5","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":22995610,"name":"puppetlabs-strings","full_name":"puppetlabs/puppetlabs-strings","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppetlabs-strings","description":"The next generation puppet documentation extraction and presentation tool","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings","forks_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/releases{/id}","created_at":"2014-08-15T16:26:44Z","updated_at":"2015-05-07T10:21:03Z","pushed_at":"2015-07-09T18:41:40Z","git_url":"git://github.com/puppetlabs/puppetlabs-strings.git","ssh_url":"git@github.com:puppetlabs/puppetlabs-strings.git","clone_url":"https://github.com/puppetlabs/puppetlabs-strings.git","svn_url":"https://github.com/puppetlabs/puppetlabs-strings","homepage":null,"size":550,"stargazers_count":30,"watchers_count":30,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33"},"html":{"href":"https://github.com/puppetlabs/puppetlabs-strings/pull/33"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/33"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppetlabs-strings/statuses/64dd545318180b3c41538499599ffcdb0ab309f5"}}}}