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

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, and usage is here:

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,

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

    def _buildLines(self):
            iface = _resolve_dotted_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(, 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:
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). :)

Repoze-dev mailing list

Reply via email to