Seems this depends on docutils 0.5, as when used with docutils 0.4, it
tries to import Directive from docutils.parsers.rst. Which isn't
there.

Upon updating docutils, it seems like it may not like sphinx 0.6.1. On
line 112, it calls:

    app.add_directive('autointerface', AutoInterfaceDirective,
                      0, (1, 0, 1) )

Which results in sphinx complaining:

"when adding directive classes, no additional arguments may be given"

add_directive comes from sphinx's application.py, and usage is here:

http://sphinx.pocoo.org/ext/appapi.html#sphinx.application.Sphinx.add_directive

What seems to be the relevant portion is:

--------------

There are two possible ways to write a directive:

In the docutils 0.4 style, func is the directive function. content,
arguments and options are set as attributes on the function and
determine whether the directive has content, arguments and options,
respectively.

In the docutils 0.5 style, directiveclass is the directive class. It
must already have attributes named has_content, required_arguments,
optional_arguments, final_argument_whitespace and option_spec that
correspond to the options for the function way. See the Docutils docs
for details.

The directive class normally must inherit from the class
docutils.parsers.rst.Directive. When writing a directive for usage in
a Sphinx extension, you inherit from sphinx.util.compat.Directive
instead which does the right thing even on docutils 0.4 (which doesn’t
support directive classes otherwise).

---------------

So I'm not sure how this ever worked, as it seems that it requires
docutils 0.5, but it uses the docutils 0.4 usage of add_directive.
Commenting out the additional parameters to add_directive seems to
solve it. It might also be solved by inheriting from
sphinx.util.compat.Directive, if you have not already installed
docutils 0.5.

Once installed, awesome!

Except that if you use autointerface like autoclass, and pass in a
relative class (which would be convenient), it raises a ValueError,
which is not caught and converted to a Sphinx warning, the way
IndexError and AttributeError are.

Lines 29-36 of autointerface.py:

    def _buildLines(self):
        try:
            iface = _resolve_dotted_name(self.name)
        except (ImportError, AttributeError):#, ValueError):
            return [self.state.document.reporter.warning(
                'autointerface can\'t import/find %r: \n'
                'please check your spelling and sys.path' %
                str(self.name), line=self.lineno)]

Adding ValueError to that list, it does get converted properly, and is
returned from _buildLines, however, there is a subsequent exception
generated, where Sphinx complains:

Exception occurred:
  File 
"c:\python25\lib\site-packages\docutils-0.5-py2.5.egg\docutils\statemachine.py",
line 434, in match
    return pattern.match(self.line)
TypeError: expected string or buffer

(Note that this also occurs if you misspell the the interface path)

I don't have time to debug this any further, but I thought it would be
useful information.

Finally, thanks! autointerface is probably going to save me almost as
much time today as I took debugging it (and much more in the long
run). :)

Alec
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to