mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3079: texinfo: image files are not copied on `make install-info
`
This commit is contained in:
parent
ac9e9c0745
commit
7a5aa822f6
3
CHANGES
3
CHANGES
@ -7,6 +7,8 @@ Dependencies
|
|||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
* texinfo: image files are copied into ``name-figure`` directory
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@ -22,6 +24,7 @@ Bugs fixed
|
|||||||
* #5508: ``linenothreshold`` option for ``highlight`` directive was ignored
|
* #5508: ``linenothreshold`` option for ``highlight`` directive was ignored
|
||||||
* texinfo: ``make install-info`` causes syntax error
|
* texinfo: ``make install-info`` causes syntax error
|
||||||
* texinfo: ``make install-info`` fails on macOS
|
* texinfo: ``make install-info`` fails on macOS
|
||||||
|
* #3079: texinfo: image files are not copied on ``make install-info``
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -27,7 +27,7 @@ from sphinx.util.console import darkgreen # type: ignore
|
|||||||
from sphinx.util.docutils import new_document
|
from sphinx.util.docutils import new_document
|
||||||
from sphinx.util.fileutil import copy_asset_file
|
from sphinx.util.fileutil import copy_asset_file
|
||||||
from sphinx.util.nodes import inline_all_toctrees
|
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
|
from sphinx.writers.texinfo import TexinfoWriter, TexinfoTranslator
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
@ -134,6 +134,7 @@ class TexinfoBuilder(Builder):
|
|||||||
settings.docname = docname
|
settings.docname = docname
|
||||||
doctree.settings = settings
|
doctree.settings = settings
|
||||||
docwriter.write(doctree, destination)
|
docwriter.write(doctree, destination)
|
||||||
|
self.copy_image_files(targetname[:-5])
|
||||||
|
|
||||||
def assemble_doctree(self, indexfile, toctree_only, appendices):
|
def assemble_doctree(self, indexfile, toctree_only, appendices):
|
||||||
# type: (str, bool, List[str]) -> nodes.document
|
# type: (str, bool, List[str]) -> nodes.document
|
||||||
@ -180,11 +181,10 @@ class TexinfoBuilder(Builder):
|
|||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
self.copy_image_files()
|
|
||||||
self.copy_support_files()
|
self.copy_support_files()
|
||||||
|
|
||||||
def copy_image_files(self):
|
def copy_image_files(self, targetname):
|
||||||
# type: () -> None
|
# type: (str) -> None
|
||||||
if self.images:
|
if self.images:
|
||||||
stringify_func = ImageAdapter(self.app.env).get_original_image_uri
|
stringify_func = ImageAdapter(self.app.env).get_original_image_uri
|
||||||
for src in status_iterator(self.images, __('copying images... '), "brown",
|
for src in status_iterator(self.images, __('copying images... '), "brown",
|
||||||
@ -192,8 +192,9 @@ class TexinfoBuilder(Builder):
|
|||||||
stringify_func=stringify_func):
|
stringify_func=stringify_func):
|
||||||
dest = self.images[src]
|
dest = self.images[src]
|
||||||
try:
|
try:
|
||||||
copy_asset_file(path.join(self.srcdir, src),
|
imagedir = path.join(self.outdir, targetname + '-figures')
|
||||||
path.join(self.outdir, dest))
|
ensuredir(imagedir)
|
||||||
|
copy_asset_file(path.join(self.srcdir, dest), imagedir)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.warning(__('cannot copy image file %r: %s'),
|
logger.warning(__('cannot copy image file %r: %s'),
|
||||||
path.join(self.srcdir, src), err)
|
path.join(self.srcdir, src), err)
|
||||||
|
@ -20,12 +20,18 @@ install-info: info
|
|||||||
for f in *.info; do \
|
for f in *.info; do \
|
||||||
mkdir -p $(infodir) && \
|
mkdir -p $(infodir) && \
|
||||||
cp "$$f" $(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
|
done
|
||||||
|
|
||||||
uninstall-info: info
|
uninstall-info: info
|
||||||
for f in *.info; do \
|
for f in *.info; do \
|
||||||
rm -f "$(infodir)/$$f" ; \
|
rm -f "$(infodir)/$$f" ; \
|
||||||
|
rm -rf "$(infodir)/`basename '$$f' .info`-figures" && \
|
||||||
$(INSTALL_INFO) --delete --info-dir=$(infodir) "$$f" ; \
|
$(INSTALL_INFO) --delete --info-dir=$(infodir) "$$f" ; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1355,8 +1355,9 @@ class TexinfoTranslator(SphinxTranslator):
|
|||||||
width = self.tex_image_length(attrs.get('width', ''))
|
width = self.tex_image_length(attrs.get('width', ''))
|
||||||
height = self.tex_image_length(attrs.get('height', ''))
|
height = self.tex_image_length(attrs.get('height', ''))
|
||||||
alt = self.escape_arg(attrs.get('alt', ''))
|
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' %
|
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):
|
def depart_image(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
|
Loading…
Reference in New Issue
Block a user