{"action":"created","issue":{"url":"https://api.github.com/repos/sphinx-doc/testing2/issues/94","labels_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/94/comments","events_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/94/events","html_url":"https://github.com/sphinx-doc/testing2/issues/94","id":53252318,"number":94,"title":"Add source link to classes and method","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/duplicate","name":"duplicate","color":"cccccc"},{"url":"https://api.github.com/repos/sphinx-doc/testing2/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-02T13:22:53Z","updated_at":"2015-01-02T13:23:02Z","closed_at":"2015-01-02T13:22:54Z","body":"I start hacking autodoc in Sphinx to add a //source// link after each class/method/function name. This link will link to web page showing the code of the current module, like the browse view in Trac.\n\nTo attemp to do this I hack the //desc_directive()// function like this (from line 420:\n    \n    #!python\n    \n        for i, sig in enumerate(signatures):\n            # add a signature node for each signature in the current unit\n            # and add a reference target for it\n            sig = sig.strip()\n            signode = addnodes.desc_signature(sig, '')\n            signode['first'] = False\n            \n            # MY CODE START HERE\n            # Create a reference\n            newnode = nodes.reference('', '')\n            innernode = nodes.emphasis('Source', 'Source')\n            newnode['refuri'] = 'https://www.example.com/trac/project/browser/trunk/py/' + options['module'].replace('.', '/') + '.py'\n            newnode.append(innernode)\n            signode.append(newnode)\n            # MY CODE FINISH HERE\n    \n            node.append(signode)\n    \n    \n\nThis is really preliminary code with everything hard coded. In the final version the URL will be taken from the conf.py file and a directive option (like :source:) will be added to the automodule directive.\n\nSide note: I saw your proposal //Easily extendable autodoc// (issue #3), it looks a very very good idea. Any idea of a timeframe for when you will add this ? Hacking //desc_directive()// is not a good way to go.\n\nIn my attemp to do this I hit 2 problems:\n\nThe first one is the //Source// link was in front of the method name instead of after (HTML output):\n    \n    #!html\n    \n    <dt id=\"ui.cli.cli.CliController\">\n    <!--[ui.cli.cli.CliController]-->\n    class <a class=\"reference external\" href=\"www.example.com/trac/project/browser/trunk/py/ui/cli/cli.py\"><em>Source</em></a>\n    <tt class=\"descname\">CliController</tt>\n    <big>(</big><em>subject</em><big>)</big>\n    <a class=\"headerlink\" href=\"#ui.cli.cli.CliController\" title=\"Permalink to this definition\">¶</a>\n    </dt>\n    \n\nI have no idea why because the nodes I add are childrens of the signode ?\n\nMy second problem is that I wish to add the line number to the URL of the class/method/function so we can jump directly to the good place in the code. The URL will be of this form:\nwww.example.com/trac/project/browser/trunk/py/ui/cli/cli.py#L234\n\nThere's a //lineno// variable in the //desc_directive()// function, but the number it give don't correspond to the real line number. But after I dig a little more into the Sphinx/docutils code, I was with the impression that //lineno// is supposed to be the real line number ?\n\nIs there's a way to get the real line number (line number in the script file) in the //desc_directive()// function ?\n\n----------------------------------------\n- Bitbucket: https://bitbucket.org/birkenfeld/sphinx/issue/94\n- Originally reported by: Anonymous\n- Originally created at: 2009-01-16T20:30:23.463\n"},"comment":{"url":"https://api.github.com/repos/sphinx-doc/testing2/issues/comments/68526154","html_url":"https://github.com/sphinx-doc/testing2/issues/94#issuecomment-68526154","issue_url":"https://api.github.com/repos/sphinx-doc/testing2/issues/94","id":68526154,"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-02T13:23:01Z","updated_at":"2015-01-02T13:23:01Z","body":"_From Anonymous on 2009-07-21 10:52:19+00:00_\n\nOnline shopping is a wonderful way to save time as well as money.<<issue http://www.coupons4save.comAnjolee>> often have great sales and many even have free shipping coupons. These tips will help you find the coolest gifts for the best prices, all without leaving your house."}}