{"action":"created","issue":{"url":"https://api.github.com/repos/sphinx-doc/testing2/issues/681","labels_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/681/labels{/name}","comments_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/681/comments","events_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/681/events","html_url":"https://github.com/sphinx-doc/testing2/issues/681","id":53281105,"number":681,"title":"[PATCH] proper parameter formatting better default arg handling in :cpp:function","user":{"login":"shimizukawa","id":151623,"avatar_url":"https://avatars.githubusercontent.com/u/151623?v=3","gravatar_id":"","url":"https://api.github.com/users/shimizukawa","html_url":"https://github.com/shimizukawa","followers_url":"https://api.github.com/users/shimizukawa/followers","following_url":"https://api.github.com/users/shimizukawa/following{/other_user}","gists_url":"https://api.github.com/users/shimizukawa/gists{/gist_id}","starred_url":"https://api.github.com/users/shimizukawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shimizukawa/subscriptions","organizations_url":"https://api.github.com/users/shimizukawa/orgs","repos_url":"https://api.github.com/users/shimizukawa/repos","events_url":"https://api.github.com/users/shimizukawa/events{/privacy}","received_events_url":"https://api.github.com/users/shimizukawa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sphinx-doc/testing2/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/sphinx-doc/testing2/labels/domains%3Acpp","name":"domains:cpp","color":"FFFFFF"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/sphinx-doc/testing2/milestones/2","labels_url":"https://api.github.com/repos/sphinx-doc/testing2/milestones/2/labels","id":919560,"number":2,"title":"1.x","description":null,"creator":{"login":"shimizukawa","id":151623,"avatar_url":"https://avatars.githubusercontent.com/u/151623?v=3","gravatar_id":"","url":"https://api.github.com/users/shimizukawa","html_url":"https://github.com/shimizukawa","followers_url":"https://api.github.com/users/shimizukawa/followers","following_url":"https://api.github.com/users/shimizukawa/following{/other_user}","gists_url":"https://api.github.com/users/shimizukawa/gists{/gist_id}","starred_url":"https://api.github.com/users/shimizukawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shimizukawa/subscriptions","organizations_url":"https://api.github.com/users/shimizukawa/orgs","repos_url":"https://api.github.com/users/shimizukawa/repos","events_url":"https://api.github.com/users/shimizukawa/events{/privacy}","received_events_url":"https://api.github.com/users/shimizukawa/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":33,"state":"open","created_at":"2015-01-02T11:47:53Z","updated_at":"2015-01-02T22:03:33Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-01-02T22:03:32Z","updated_at":"2015-01-02T22:03:35Z","closed_at":"2015-01-02T22:03:33Z","body":"Hello,\n\nThis is a patch for sphinx/domains/cpp.py from Sphinx 1.0.7 that adds :param: directive support to :cpp:function: and also handles the default parameters containing parentheses, e.g. :cpp:function: void MyClass::foo(const string& name=string());\n\nRegards,\nVadim\n\n    \n    --- /Users/vp/Downloads/Sphinx-1.0.7/sphinx/domains/cpp.py\t2011-01-08 18:05:59.000000000 +0300\n    +++ /Users/vp/Downloads/Sphinx-1.0.7/sphinx/domains/cpp2.py\t2011-04-19 16:10:06.000000000 +0400\n    @@ -21,7 +21,7 @@\n     from sphinx.directives import ObjectDescription\n     from sphinx.util.nodes import make_refnode\n     from sphinx.util.compat import Directive\n    -\n    +from sphinx.util.docfields import Field, TypedField\n     \n     _identifier_re = re.compile(r'(~?\\b[a-zA-Z_][a-zA-Z0-9_]*)\\b')\n     _whitespace_re = re.compile(r'\\s+(?u)')\n    @@ -658,17 +658,33 @@\n             self.skip_ws()\n             if self.match(_string_re):\n                 return self.matched_text\n    -        idx1 = self.definition.find(',', self.pos)\n    -        idx2 = self.definition.find(')', self.pos)\n    -        if idx1 < 0:\n    -            idx = idx2\n    -        elif idx2 < 0:\n    -            idx = idx1\n    -        else:\n    -            idx = min(idx1, idx2)\n    -        if idx < 0:\n    -            self.fail('unexpected end in default expression')\n    -        rv = self.definition[self.pos:idx]\n    +        paren_stack_depth = 0\n    +        max_pos = len(self.definition)\n    +        rv_start = self.pos\n    +        while 1:\n    +            idx0 = self.definition.find('(', self.pos)\n    +            idx1 = self.definition.find(',', self.pos)\n    +            idx2 = self.definition.find(')', self.pos)\n    +            if idx0 < 0:\n    +                idx0 = max_pos\n    +            if idx1 < 0:\n    +                idx1 = max_pos\n    +            if idx2 < 0:\n    +                idx2 = max_pos\n    +            idx = min(idx0, idx1, idx2)\n    +            if idx >= max_pos:\n    +                self.fail('unexpected end in default expression')\n    +            if idx == idx0:\n    +                paren_stack_depth += 1\n    +            elif idx == idx2:\n    +                paren_stack_depth -= 1\n    +                if paren_stack_depth < 0:\n    +                    break\n    +            elif paren_stack_depth == 0:\n    +                break\n    +            self.pos = idx+1\n    +            \n    +        rv = self.definition[rv_start:idx]\n             self.pos = idx\n             return rv\n     \n    @@ -788,6 +804,16 @@\n     class CPPObject(ObjectDescription):\n         \"\"\"Description of a C++ language object.\"\"\"\n     \n    +    doc_field_types = [\n    +        TypedField('parameter', label=l_('Parameters'),\n    +                   names=('param', 'parameter', 'arg', 'argument'),\n    +                   typerolename='type', typenames=('type',)),\n    +        Field('returnvalue', label=l_('Returns'), has_arg=False,\n    +              names=('returns', 'return')),\n    +        Field('returntype', label=l_('Return type'), has_arg=False,\n    +              names=('rtype',)),\n    +    ]\n    +\n         def attach_name(self, node, name):\n             owner, name = name.split_owner()\n             varname = unicode(name)\n    \n\n----------------------------------------\n- Bitbucket: https://bitbucket.org/birkenfeld/sphinx/issue/681\n- Originally reported by: Anonymous\n- Originally created at: 2011-04-19T14:16:38.642\n"},"comment":{"url":"https://api.github.com/repos/sphinx-doc/testing2/issues/comments/68566823","html_url":"https://github.com/sphinx-doc/testing2/issues/681#issuecomment-68566823","issue_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/681","id":68566823,"user":{"login":"shimizukawa","id":151623,"avatar_url":"https://avatars.githubusercontent.com/u/151623?v=3","gravatar_id":"","url":"https://api.github.com/users/shimizukawa","html_url":"https://github.com/shimizukawa","followers_url":"https://api.github.com/users/shimizukawa/followers","following_url":"https://api.github.com/users/shimizukawa/following{/other_user}","gists_url":"https://api.github.com/users/shimizukawa/gists{/gist_id}","starred_url":"https://api.github.com/users/shimizukawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shimizukawa/subscriptions","organizations_url":"https://api.github.com/users/shimizukawa/orgs","repos_url":"https://api.github.com/users/shimizukawa/repos","events_url":"https://api.github.com/users/shimizukawa/events{/privacy}","received_events_url":"https://api.github.com/users/shimizukawa/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T22:03:34Z","updated_at":"2015-01-02T22:03:34Z","body":"_From Jeroen Keiren on 2012-01-03 15:21:29+00:00_\n\nI second that this is a useful modification. It applies mostly cleanly to the current development version, and it would be great to have this change in the next release.\r\n\r\nThe patch fixes all issues of functions with default parameters that I have run into so far."}}