sphinx-contrib / restbuilder

A Sphinx builder/writer to output reStructuredText (rst) files
BSD 2-Clause "Simplified" License
31 stars 27 forks source link

Error rendering image directive #7

Closed anthonyray closed 4 years ago

anthonyray commented 5 years ago

First of all, thanks for this extension !

I use restbuilder to generate a README.rst file that serves as the README of Github repository. I have the following folder hierarchy : documentation > source > README.rst and when I build the documentation, I get a documentation > build > README.rst file that I later move to the root of my repository to serve as the main README.

I need to render the source/README.rst because it contains directives such as .. include and .. image.

For instance, I would like to display badges for my project, in my source README.rst I have :

.. image
   :target: https://thewebsitethathostsmybadge.com/myproject.svg

But I get the following error, with the associated stacktrace :

#   sphinx.ext.mathjax (1.8.3) from ~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   alabaster (0.7.12) from ~~~REPLACED~~~env37/lib/python3.7/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.8.3) from ~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.doctest (1.8.3) from ~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/ext/doctest.py
#   sphinxcontrib.restbuilder (unknown version) from ~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinxcontrib/restbuilder.py
Traceback (most recent call last):
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/cmd/build.py", line 304, in build_main
    app.build(args.force_all, filenames)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/application.py", line 341, in build
    self.builder.build_update()
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 347, in build_update
    len(to_build))
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 412, in build
    self.write(docnames, list(updated_docnames), method)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 593, in write
    self._write_serial(sorted(docnames))
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 604, in _write_serial
    self.write_doc(docname, doctree)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinxcontrib/builders/rst.py", line 130, in write_doc
    self.writer.write(doctree, destination)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinxcontrib/writers/rst.py", line 40, in translate
    self.document.walkabout(visitor)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/nodes.py", line 174, in walkabout
    if child.walkabout(visitor):
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/nodes.py", line 166, in walkabout
    visitor.dispatch_visit(self)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
    return method(node)
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/sphinxcontrib/writers/rst.py", line 712, in visit_reference
    self.add_text('`%s <%s>`_' % (node['name'], node['refuri']))
  File "~~~REPLACED~~~env37/lib/python3.7/site-packages/docutils/nodes.py", line 567, in __getitem__
    return self.attributes[key]
KeyError: 'name'

Can someone help me out here ?

mortenvp commented 5 years ago

I also go this issue. Did you find a solution?

anthonyray commented 5 years ago

@mortenvp , unfortunately no ...

macfreek commented 4 years ago

With apologies for leaving this hanging, it should be merged in #8. Thanks for the PR.