Daniele Varrazzo <[email protected]> writes:

> Hello,
>
> I am writing documentation for Psycopg (yay!) using Sphinx and I have
> a problem with links between methods in the same class.
>
>>From Sphinx documentation [1] I read that i can refer to methods in
> the same class using the :meth: role without specifying the class
> name. I see the feature used e.g. in the Python doc for Thread.join()
> [2], where references :meth:`isAlive` are converted in a link.
>
> I tried to use the feature, but no link is created: for instance in
> [3] I tried to use :meth:`fetchmany` but no link is created, unless I
> use explicitely :meth:`cursor.fetchmany`. :meth:`.fetchmany`doesn't
> work either. No warning is issued either.
>
> Can you explain why is this happening? I'm using Sphinx 0.6.4 with a
> conf script mostly generated by sphinx-quickstart.

It seems the class settings are reset on every headline, including
.. rubric::

As I had similar problems I created "currentclass" directive that works
just like "currentmodule". Would be nice to have it included with future
Sphinx versions.

--8<---------------cut here---------------start------------->8---
from docutils.parsers.rst import directives
from docutils.parsers.rst import roles

from sphinx.util.compat import directive_dwim, Directive
from sphinx.directives.desc import ClassmemberDesc
from sphinx.roles import xfileref_role


class CurrentClass(Directive):
    """
    This directive is just to tell Sphinx that we're documenting
    stuff in class Foo, but links to class Foo won't lead here.
    """
        
    has_content = False
    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = False
    option_spec = {}
     
    def run(self):
        env = self.state.document.settings.env
        classname = self.arguments[0].strip()
        if classname == 'None':
            env.currclass = None
        else:
            env.currclass = classname
        return []
        

def setup(app):
    directives.register_directive('currentclass', directive_dwim(CurrentClass))

--8<---------------cut here---------------end--------------->8---




   Florian
-- 
GUIs programmieren mit Python und Glade:
<http://www.florian-diesch.de/doc/python-und-glade/>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to