Fix #3079: texinfo: image files are not copied on `make install-info`

This commit is contained in:
Takeshi KOMIYA 2019-03-02 18:25:26 +09:00
parent ac9e9c0745
commit 7a5aa822f6
4 changed files with 19 additions and 8 deletions

View File

@ -7,6 +7,8 @@ Dependencies
Incompatible changes
--------------------
* texinfo: image files are copied into ``name-figure`` directory
Deprecated
----------
@ -22,6 +24,7 @@ Bugs fixed
* #5508: ``linenothreshold`` option for ``highlight`` directive was ignored
* texinfo: ``make install-info`` causes syntax error
* texinfo: ``make install-info`` fails on macOS
* #3079: texinfo: image files are not copied on ``make install-info``
Testing
--------

View File

@ -27,7 +27,7 @@ from sphinx.util.console import darkgreen # type: ignore
from sphinx.util.docutils import new_document
from sphinx.util.fileutil import copy_asset_file
from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import SEP, make_filename_from_project
from sphinx.util.osutil import SEP, ensuredir, make_filename_from_project
from sphinx.writers.texinfo import TexinfoWriter, TexinfoTranslator
if False:
@ -134,6 +134,7 @@ class TexinfoBuilder(Builder):
settings.docname = docname
doctree.settings = settings
docwriter.write(doctree, destination)
self.copy_image_files(targetname[:-5])
def assemble_doctree(self, indexfile, toctree_only, appendices):
# type: (str, bool, List[str]) -> nodes.document
@ -180,11 +181,10 @@ class TexinfoBuilder(Builder):
def finish(self):
# type: () -> None
self.copy_image_files()
self.copy_support_files()
def copy_image_files(self):
# type: () -> None
def copy_image_files(self, targetname):
# type: (str) -> None
if self.images:
stringify_func = ImageAdapter(self.app.env).get_original_image_uri
for src in status_iterator(self.images, __('copying images... '), "brown",
@ -192,8 +192,9 @@ class TexinfoBuilder(Builder):
stringify_func=stringify_func):
dest = self.images[src]
try:
copy_asset_file(path.join(self.srcdir, src),
path.join(self.outdir, dest))
imagedir = path.join(self.outdir, targetname + '-figures')
ensuredir(imagedir)
copy_asset_file(path.join(self.srcdir, dest), imagedir)
except Exception as err:
logger.warning(__('cannot copy image file %r: %s'),
path.join(self.srcdir, src), err)

View File

@ -20,12 +20,18 @@ install-info: info
for f in *.info; do \
mkdir -p $(infodir) && \
cp "$$f" $(infodir) && \
$(INSTALL_INFO) --info-dir=$(infodir) "$$f" ; \
$(INSTALL_INFO) --info-dir=$(infodir) "$$f" && \
\
FIGURE_DIR="`basename \"$$f\" .info`-figures" && \
if [ -e "$$FIGURE_DIR" ]; then \
cp -r "$$FIGURE_DIR" $(infodir) ; \
fi; \
done
uninstall-info: info
for f in *.info; do \
rm -f "$(infodir)/$$f" ; \
rm -rf "$(infodir)/`basename '$$f' .info`-figures" && \
$(INSTALL_INFO) --delete --info-dir=$(infodir) "$$f" ; \
done

View File

@ -1355,8 +1355,9 @@ class TexinfoTranslator(SphinxTranslator):
width = self.tex_image_length(attrs.get('width', ''))
height = self.tex_image_length(attrs.get('height', ''))
alt = self.escape_arg(attrs.get('alt', ''))
filename = "%s-figures/%s" % (self.elements['filename'][:-5], name) # type: ignore
self.body.append('\n@image{%s,%s,%s,%s,%s}\n' %
(name, width, height, alt, ext[1:]))
(filename, width, height, alt, ext[1:]))
def depart_image(self, node):
# type: (nodes.Element) -> None