Issues

Issue #1355 resolved

AttributeError using sphinx 1.2.1

Anonymous created an issue

I upgraded my sphinx using pip, which installed sphinx 1.2.1 on my Mac OS X 10.9.1

I got this exception while compiling the latest stable version of Django docs:

# Sphinx version: 1.2.1
# Python version: 2.7.5
# Docutils version: 0.11 release
# Jinja2 version: 2.7.2
# Loaded extensions:
#   djangodocs from /Users/reza/Workspaces/django/docs/_ext/djangodocs.pyc
#   sphinx.ext.oldcmarkup from /Library/Python/2.7/site-packages/sphinx/ext/oldcmarkup.pyc
#   sphinx.ext.intersphinx from /Library/Python/2.7/site-packages/sphinx/ext/intersphinx.pyc

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/sphinx/cmdline.py", line 254, in main
    app.build(force_all, filenames)
  File "/Library/Python/2.7/site-packages/sphinx/application.py", line 212, in build
    self.builder.build_update()
  File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 214, in build_update
    'out of date' % len(to_build))
  File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 276, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 320, in write
    self._write_serial(sorted(docnames), warnings)
  File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 333, in _write_serial
    self.write_doc(docname, doctree)
  File "/Library/Python/2.7/site-packages/sphinx/builders/html.py", line 433, in write_doc
    self.docwriter.write(doctree, destination)
  File "/Library/Python/2.7/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 51, in translate
    self.document.walkabout(visitor)
  File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
... (5 more of the same)
  File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 166, in walkabout
    visitor.dispatch_visit(self)
  File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
    return method(node)
  File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 153, in visit_desc_parameter
    if self.optional_param_level == 0:
AttributeError: DjangoHTMLTranslator instance has no attribute 'optional_param_level'

Comments (12)

  1. Georg Brandl repo owner

    Thanks for the report. This is not really a Sphinx issue (Django has to adapt their extension) but I pushed a fix that should make it work until they do.

  2. Tim Graham

    Here's the fix I pushed for the Django docs. It looks like we're overriding the method just to remove the <big> tag that sphinx uses by default. Perhaps we could add a hook for that so that Django can make this change more elegantly.

  3. Georg Brandl repo owner

    I don't think a hook for a single tag is sensible, but as I said, if it's a <span class="whatever"> you can easily style that as you like for Django.

  4. Barry Warsaw

    We saw this failure in our Ubuntu archive test rebuild, and the patch Georg applied fixed that particular problem. Now we're seeing this failure:

    Exception occurred:
      File "/usr/lib/python2.7/dist-packages/sphinx/writers/html.py", line 155, in visit_desc_parameter
        self.required_params_left -= 1
    AttributeError: DjangoHTMLTranslator instance has no attribute 'required_params_left'
    

    So I'm guessing a similar patch is required to fix this?

  5. Ned Batchelder

    I just dealt with this in my own extension. Perhaps the best thing would be to separate the base method into two parts: 1) output the actual text, and 2) set internal state. Then I could override #1, and just call #2. As it is, I'm doing just what Django did, copying a bunch of lines from the base class into mine.

  6. Log in to comment