rst2pdf does not work with the Sphinx glossary directive
See original GitHub issueWhen using rst2pdf with the Sphinx glossary directive, rst2pdf raises the following ValueError
for the first defined term in the glossary:
ValueError: format not resolved, probably missing URL scheme or undefined destination target for 'term-abs'
For the above example, the glossary directive starts with:
.. glossary::
ABS
Anti-Lock Braking System
And the glossary
directive generates a term-%
destination target for each defined term in the glossary.
Description of problem
To reproduce the problem:
- Install the following
requirements.txt
file withpip
in a python 3.6 environment (I am using Ubuntu 18.04LTS).sphinx==3.2.0 rst2pdf==0.97
- Create a new documentation project, configuring
rst2pdf
inconf.py
:extensions = [ ... 'rst2pdf.pdfbuilder', ... ] pdf_documents = [ ( 'index', u'rst2pdf', project, author ), ]
- Modify the
Makefile
to use Python 3:SPHINXBUILD ?= python3 $(shell which sphinx-build)
- Add a glossary to the
index.rst
:.. glossary:: RST Restructured Text
- Build a
pdf
:make pdf
I am proposing that rst2pdf
adds support for the Sphinx glossary directive directive, which would make rst2pdf
that much more useful for dissertations and technical documents.
I have already tried hacking the rst2pdf
code to get this working, but while I am highly proficient in python, some guidance with Sphinx and rst2pdf
would be appreciated.
What is the expected output? What do you see instead?
I am expecting that a pdf file is generated, but the build fails with the following stack-trace:
Traceback (most recent call last):
File "/home/smith/.local/lib/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 146, in write
docwriter.write(doctree, destination)
File "/usr/local/lib/python3.6/dist-packages/docutils/writers/__init__.py", line 78, in write
self.translate()
File "/home/smith/.local/lib/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 646, in translate
compressed=self.compressed)
File "/home/smith/.local/lib/python3.6/site-packages/rst2pdf/createpdf.py", line 643, in createPdf
pdfdoc.multiBuild(elements)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/platypus/doctemplate.py", line 1153, in multiBuild
self.canv.save()
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfgen/canvas.py", line 1244, in save
self._doc.SaveToFile(self._filename, self)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 219, in SaveToFile
data = self.GetPDFData(canvas)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 245, in GetPDFData
return self.format()
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 427, in format
IOf = IO.format(self)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 875, in format
fcontent = format(self.content, document, toplevel=1) # yes this is at top level
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 80, in format
f = element.format(document)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 1612, in format
return D.format(document)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 683, in format
L = [(format(PDFName(k),document)+b" "+format(dict[k],document)) for k in keys]
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 683, in <listcomp>
L = [(format(PDFName(k),document)+b" "+format(dict[k],document)) for k in keys]
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 80, in format
f = element.format(document)
File "/home/smith/.local/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 1778, in format
if f is None: raise ValueError("format not resolved, probably missing URL scheme or undefined destination target for '%s'" % self.name)
ValueError: format not resolved, probably missing URL scheme or undefined destination target for 'term-abs'
🖥 Versions
$ python3 -V
Python 3.6.9
$ pip3 freeze | grep rst2pdf
rst2pdf==0.97
$ pip3 freeze | grep reportlab
reportlab==3.5.47
$ pip3 freeze | grep Sphinx
Sphinx==3.2.0
Which operating system are you using?
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
I also have to install textlive-font-utils
on Ubuntu, which is at version 2017.20180305-2
.
Additional information
I need this change to be able to simply generate pdf’s for small to medium technical documentation without getting entrenched in the complexities of latexpdf
. I am quite certain this will be of generic value to other users writing documentation requiring glossaries.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
With a little guidance on the rst2pdf and Sphinx architectures, I am fairly certain that I can make a pull-request for this. Can someone provide some guidance?
@sachin-suresh-rapyuta, this issue has not be resolved and we would love help to fix it.