bitprophet / releases

A powerful Sphinx changelog-generating extension.
http://releases.readthedocs.io/
BSD 2-Clause "Simplified" License
176 stars 41 forks source link

NotImplementedError: Unknown node: issue #32

Closed pmuller closed 10 years ago

pmuller commented 10 years ago

Using releases 0.6.1 and most earlier versions, I get the same exception as in #22 and #24. Here is the Sphinx error log :

# Sphinx version: 1.2.2
# Python version: 2.7.6
# Docutils version: 0.11 release
# Jinja2 version: 2.7.2
# Loaded extensions:
#   sphinx.ext.todo from /home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/ext/todo.pyc
#   sphinxcontrib.programoutput from /home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinxcontrib/programoutput.pyc
#   releases from /home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/releases/__init__.pyc
#   sphinx.ext.intersphinx from /home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/ext/intersphinx.pyc
#   sphinx.ext.oldcmarkup from /home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/ext/oldcmarkup.pyc
Traceback (most recent call last):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/cmdline.py", line 254, in main
    app.build(force_all, filenames)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/application.py", line 212, in build
    self.builder.build_update()
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 214, in build_update
    'out of date' % len(to_build))
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 276, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 320, in write
    self._write_serial(sorted(docnames), warnings)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 333, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/builders/html.py", line 433, in write_doc
    self.docwriter.write(doctree, destination)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/writers/html.py", line 51, in translate
    self.document.walkabout(visitor)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 166, in walkabout
    visitor.dispatch_visit(self)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
    return method(node)
  File "/home/pmuller/dev/ipkg/env/lib/python2.7/site-packages/sphinx/writers/html.py", line 588, in unknown_visit
    raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
NotImplementedError: Unknown node: issue

Since this changelog.rst does not belong to an opensource project, I'll send it to you by e-mail.

I tried many versions of release; and the 0.2.4 version builds this changelog.rst file successfully. More recent ones do not.

Thanks for your help !

bitprophet commented 10 years ago

@pmuller mailed me a copy of his (non public) changelog file, and after bisecting it I realized it was actually quite simple.

The changelog was lacking an initial release line, meaning that the final couple of changelog lines had no release. In other words, it looked like this:

* :release:`0.14.1 <date>`
* :bug:`0` bugs and such here
.. <a bunch more releases and issue lines, as usual>
* :release:`0.5.0 <date>`
* :feature:`0` early feature 2
* :feature:`0` early feature 1
.. notice there is no initial release here! this is the end of the file.

Releases scans the changelog file bottom-up, so if there is no 'first' (from that perspective) release, it has no idea what release those first two early features belong to.

I'll see what I can do so that Releases detects this and yields a more useful error, and if the docs could use an extra warning or something.

@pmuller - so if you put an e.g. '0.4.0' release at the very bottom of your changelog - or if you remove those last two features - it should build correctly.

pmuller commented 10 years ago

Even when adding an initial release at the end of the changelog, I still get the same error. (I e-mailed the updated changelog to you).

Moreover, releases' own changelog does not have an initial release (it also starts with a feature). So I'm afraid I misunderstood your answer.

bitprophet commented 10 years ago

That's pretty strange, then :( Bisecting your original file clearly showed the issue only appeared when those last two lines were added back in, which is what brought me that red herring - but you're right, the new edition fails again & we do have other changelogs with trailing issues.

I bisected your new one, focusing on the end, and quickly realized it was the final feature line (I anonymized it even though it looked pretty innocuous out of context :)):

* :feature:`0` some text here that doesn't really mean anything,
   more text here that is indented 3 spaces deep.

With that line-item removed, it builds. Poked at those two lines more, noticed that if I simply dedent the 2nd line 1 space so it matches the non-bullet part of the 1st line, things build. This implies it's an invalid-ReST problem (though offhand I didn't think ReST was that picky?), which is probably preventing Releases from mutating its issue node within that section, thus leading to the error.

But I'm going to dig into it to make sure I'm right this time :)

bitprophet commented 10 years ago

Yea, that extra indent is causing ReST to turn those two lines into a definition list item, with the issue object inside the term sub-element (definition list items become an outer element wrapping one or more pairs of term/definition elements). So the final tree at this step becomes:

<list_item>
    <definition_list>
        <term>
            <issue />
            <first text line />
        </term>
        <definition>
            <second text line />
        </definition>
    </definition_list>
</list_item>

This is a situation Releases wasn't equipped to handle; it sees a 'bare' list item that doesn't start with an issue node, goes "ah, this is a vanilla list item, I'm supposed to turn those into bugs automatically", and does so. But that leaves the user-intended issue node wrapped deep within, which never gets mutated into HTML nodes, and so the HTML render step dies with the error in question.

Still poking to see what Releases can/should do here so the error (because it is still technically an error - Releases requires a specific format after all) is made more obvious or is otherwise handled.

bitprophet commented 10 years ago

@pmuller I pushed a fix now that I think does the trick; it spits out an exception in this situation (both in my tests and on your changelog file), with a reasonably verbose error message including a print of the trouble spot and a note saying "yo, recheck your syntax!".

bitprophet commented 10 years ago

@pmuller Bump :)

pmuller commented 10 years ago

Oops, I realize I never updated this issue. I'm sorry.

I actually use your patch and it works well ! Thanks :)

bitprophet commented 10 years ago

Sweet, glad to hear it :)