missinglinkelectronics / sphinxcontrib-svg2pdfconverter

Sphinx SVG to PDF converter extension
Other
21 stars 10 forks source link

updated call procedure lead to build fail multi document configuration #19

Closed Gatherer closed 2 years ago

Gatherer commented 2 years ago

During tests with Sphinx 5.x it show that the sub class calling procedure changed. Due to this the Inkscape version check will fail on a multi project configuration.

latex documents setup

latex_documents = [
    ('index_1' , 'titile_1, project_1, author_1, 'manual'),
    ('index_2 , 'titile_2, project_2, author_2, 'manual'),
]

While the configuration works if only one document is active

latex_documents = [
#    ('index_1' , 'titile_1, project_1, author_1, 'manual'),
    ('index_2 , 'titile_2, project_2, author_2, 'manual'),
]

or

latex_documents = [
    ('index_1' , 'titile_1, project_1, author_1, 'manual'),
#    ('index_2 , 'titile_2, project_2, author_2, 'manual'),
]

building both at the same time do fail with the following error.

Traceback (most recent call last):
.....
in apply_transforms
    transform.apply(**kwargs)
  File ".../documentation/venv/lib/python3.8/site-packages/sphinx/transforms/post_transforms/images.py", line 27, in apply
    self.handle(node)
  File ".../documentation/venv/lib/python3.8/site-packages/sphinx/transforms/post_transforms/images.py", line 244, in handle
    if self.convert(abs_srcpath, destpath):
  File "..../documentation/venv/lib/python3.8/site-packages/sphinxcontrib/inkscapeconverter.py", line 68, in convert
    if self._inkscape_version.startswith('1.'):
AttributeError: 'InkscapeConverter' object has no attribute '_inkscape_version'

It is always the second build which do fail.

After digging in deeper I found a changed call procedure. In 2.x the calling procedure is as follow

"""first document"""
is_available()
convert()
convert()
convert()

"""second document"""
is_available()
convert()
convert()
convert()

In 5.x the is_available function is called only once which leads to the failed version check on the second document.

"""first document"""
is_available()
convert()
convert()
convert()

"""second document"""
convert()
convert()
convert()

Because Inkscape 0.x is still widely used bot version need to be supported.