My talk.rst file causes bruce to crash

3 views
Skip to first unread message

Matt Wilson

unread,
Jul 12, 2008, 5:27:07 PM7/12/08
to bruce-users
Hi, I uploaded a file that I'd like to use with bruce here:
http://groups.google.com/group/bruce-users/web/talk.rst

When I run $ bruce talk.rst, I get this traceback:

$ bruce talk.rst
Traceback (most recent call last):
File "/home/matt/virtualenvs/bruce/bin/bruce", line 5, in <module>
bruce.main()
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
__init__.py", line 97, in main
pres = presentation.Presentation(rst_parser.parse(content),
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 493, in parse
d.decode(text)
File "build/bdist.linux-x86_64/egg/pyglet/text/formats/
structured.py", line 223, in decode
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 137, in decode_structured
doctree.walkabout(DocutilsVisitor(doctree, self))
File "/usr/lib/python2.5/site-packages/docutils-0.4-py2.5.egg/
docutils/nodes.py", line 159, in walkabout
child.walkabout(visitor)
File "/usr/lib/python2.5/site-packages/docutils-0.4-py2.5.egg/
docutils/nodes.py", line 151, in walkabout
visitor.dispatch_visit(self)
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 476, in dispatch_visit
method(node)
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 156, in visit_section
d = g.decode(node)
File "build/bdist.linux-x86_64/egg/pyglet/text/formats/
structured.py", line 223, in decode
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 207, in decode_structured
child.walkabout(visitor)
File "/usr/lib/python2.5/site-packages/docutils-0.4-py2.5.egg/
docutils/nodes.py", line 151, in walkabout
visitor.dispatch_visit(self)
File "/home/matt/virtualenvs/bruce/lib/python2.5/site-packages/bruce/
rst_parser.py", line 474, in dispatch_visit
method = getattr(self.decoder, 'visit_%s' % node_name)
AttributeError: 'DocumentGenerator' object has no attribute
'visit_docinfo'

Any ideas?

Richard Jones

unread,
Jul 12, 2008, 6:39:07 PM7/12/08
to bruce...@googlegroups.com
On Sun, Jul 13, 2008 at 7:27 AM, Matt Wilson <mw4...@gmail.com> wrote:
Hi, I uploaded a file that I'd like to use with bruce here:
http://groups.google.com/group/bruce-users/web/talk.rst

Please file a bug report at http://code.google.com/p/bruce-tpt/

I looks like it's breaking no the document info bit at the top of your presentation. You may temporarily remove that and Bruce should be happy again.


    Richard

Matt Wilson

unread,
Jul 13, 2008, 11:38:50 AM7/13/08
to bruce-users
On Jul 12, 6:39 pm, "Richard Jones" <r1chardj0...@gmail.com> wrote:
> On Sun, Jul 13, 2008 at 7:27 AM, Matt Wilson <mw44...@gmail.com> wrote:
> > Hi, I uploaded a file that I'd like to use with bruce here:
> >http://groups.google.com/group/bruce-users/web/talk.rst
>
> Please file a bug report athttp://code.google.com/p/bruce-tpt/

http://code.google.com/p/bruce-tpt/issues/detail?id=25

> I looks like it's breaking no the document info bit at the top of your
> presentation. You may temporarily remove that and Bruce should be happy
> again.

I don't think I understand what you mean. I deleted the :Author::
stuff, but still got the crash. Can you tell me exactly what lines I
should pull?

Thanks for the help.

Matt

Matt Wilson

unread,
Jul 13, 2008, 11:59:41 AM7/13/08
to bruce-users
On Jul 12, 6:39 pm, "Richard Jones" <r1chardj0...@gmail.com> wrote:
> On Sun, Jul 13, 2008 at 7:27 AM, Matt Wilson <mw44...@gmail.com> wrote:
> > Hi, I uploaded a file that I'd like to use with bruce here:
> >http://groups.google.com/group/bruce-users/web/talk.rst
>
> Please file a bug report athttp://code.google.com/p/bruce-tpt/
>
> I looks like it's breaking no the document info bit at the top of your
> presentation. You may temporarily remove that and Bruce should be happy
> again.

I think that bruce also has trouble with doctests embedded in the
code, or maybe I'm not using them right. Here's a test I ran:

$ cat test_doctest.rst
Doctest example

- Blah!

>>> 1 + 1
2
>>> def f(x):
... return x + x
...
>>> f(2)
4

And then here's the traceback:

$ bruce test_doctest.rst
'visit_doctest_block'

I'll make an issue for this also.

Richard Jones

unread,
Jul 13, 2008, 5:47:30 PM7/13/08
to bruce...@googlegroups.com
On Mon, 14 Jul 2008, Matt Wilson wrote:
> On Jul 12, 6:39 pm, "Richard Jones" <r1chardj0...@gmail.com> wrote:
> > On Sun, Jul 13, 2008 at 7:27 AM, Matt Wilson <mw44...@gmail.com> wrote:
> > > Hi, I uploaded a file that I'd like to use with bruce here:
> > >http://groups.google.com/group/bruce-users/web/talk.rst
> >
> > Please file a bug report athttp://code.google.com/p/bruce-tpt/
> >
> > I looks like it's breaking no the document info bit at the top of your
> > presentation. You may temporarily remove that and Bruce should be happy
> > again.
>
> I think that bruce also has trouble with doctests embedded in the
> code, or maybe I'm not using them right. Here's a test I ran:

Indeed. There appears to be a number of docutils node types that I don't
handle.


Richard

Matt Wilson

unread,
Jul 13, 2008, 8:14:46 PM7/13/08
to bruce-users
On Jul 13, 5:47 pm, Richard Jones <r1chardj0...@gmail.com> wrote:
> Indeed. There appears to be a number of docutils node types that I don't
> handle.

I'm not very familiar with how bruce + docutils work, but it seems
sort of like a SAX parser where a class has named methods for all
sorts of different node types.

Anyhow, what do you think about adding a __getattr__ method on the
class that provides all the named methods? The __getattr__ method
would fire in the scenarios where you haven't written a handler yet.
At the very least, __getattr__ could log the problem, and maybe even
apply some other default handler. For example, we could treat the
node like some other kind of node?

If you like this approach, I can start work on a patch to make it
happen.

Matt

Richard Jones

unread,
Jul 13, 2008, 9:18:50 PM7/13/08
to bruce...@googlegroups.com
On Mon, Jul 14, 2008 at 10:14 AM, Matt Wilson <mw4...@gmail.com> wrote:
Anyhow, what do you think about adding a __getattr__ method on the
class that provides all the named methods?  The __getattr__ method
would fire in the scenarios where you haven't written a handler yet.
At the very least, __getattr__ could log the problem, and maybe even
apply some other default handler.  For example, we could treat the
node like some other kind of node?

Adding a fallback handler is quite simple to do, but it would mask places where Bruce is ignoring markup.

Having a fallback would mean the presentation displays, but there would be no styling of those elements (which may be significant).

Happy to hear thoughts either way.


     Richard

Matt Wilson

unread,
Jul 13, 2008, 9:52:17 PM7/13/08
to bruce-users
On Jul 13, 9:18 pm, "Richard Jones" <r1chardj0...@gmail.com> wrote:
> On Mon, Jul 14, 2008 at 10:14 AM, Matt Wilson <mw44...@gmail.com> wrote:
> > Anyhow, what do you think about adding a __getattr__ method on the
> > class that provides all the named methods?  The __getattr__ method
> > would fire in the scenarios where you haven't written a handler yet.
> > At the very least, __getattr__ could log the problem, and maybe even
> > apply some other default handler.  For example, we could treat the
> > node like some other kind of node?
>
> Adding a fallback handler is quite simple to do, but it would mask places
> where Bruce is ignoring markup.

We could warn people when we do this,

>
> Having a fallback would mean the presentation displays, but there would be
> no styling of those elements (which may be significant).

But at least the script would run to completion. Right now, it just
detonates.

>
> Happy to hear thoughts either way.
>
>      Richard

It's probably obvious what I favor :)

Richard Jones

unread,
Jul 13, 2008, 11:29:08 PM7/13/08
to bruce...@googlegroups.com
On Mon, Jul 14, 2008 at 11:52 AM, Matt Wilson <mw4...@gmail.com> wrote:
On Jul 13, 9:18 pm, "Richard Jones" <r1chardj0...@gmail.com> wrote:
> Adding a fallback handler is quite simple to do, but it would mask places
> where Bruce is ignoring markup.

We could warn people when we do this,

Good idea. A warning is now generated on hitting an unhandled node (r145).


     Richard

Reply all
Reply to author
Forward
0 new messages