英文:
Sphinx-multiversion: Download file not readable
问题
I have a Sphinx documentation and would like to have a multiversion Sphinx docs.
On top of that, I have a zip file which I would like to be part of the documentation, where visitors can just click and download.
I have the zip file in ./docs/source/_downloads/examples/
folder. In one of the RST file, the download link is annotated as:
:download:`here </_downloads/examples/examples.zip>`
However, I get this error when building the docs via sphinx-multiversion "docs/source" "docs/build/html" -W --keep-going -n
:
C:\Users\<username>\AppData\Local\Temp\tmpei93x8y0d1e6ca1fe60c272b003f0bf7e611df99dc35d1d\docs\source\examples.rst:4: WARNING: download file not readable: C:\Users\<username>\AppData\Local\Temp\tmpei93x8y0d1e6ca1fe60c272b003f0bf7e611df99dc35d1d\docs\source\_downloads\examples\examples.zip
I am using Python 3.9.4
, Sphinx 7.0.1
, and sphinx-multiversion 0.2.4
.
英文:
I have a Sphinx documentation and would like to have a multiversion Sphinx docs.
On top of that, I have a zip file which I would like to be part of the documentation, where visitors can just click and download.
I have the zip file in ./docs/source/_downloads/examples/
folder. In one of the RST file, the download link is annotated as:
:download:`here </_downloads/examples/examples.zip>`
However, I get this error when building the docs via sphinx-multiversion "docs/source" "docs/build/html" -W --keep-going -n
:
C:\Users\<username>\AppData\Local\Temp\tmpei93x8y0d1e6ca1fe60c272b003f0bf7e611df99dc35d1d\docs\source\examples.rst:4: WARNING: download file not readable: C:\Users\<username>\AppData\Local\Temp\tmpei93x8y0d1e6ca1fe60c272b003f0bf7e611df99dc35d1d\docs\source\_downloads\examples\examples.zip
I am using Python 3.9.4
, Sphinx 7.0.1
and sphinx-multiversion 0.2.4
.
答案1
得分: 0
显然,sphinx-multiversion通过提交哈希存档文件,因此如果在本地进行更改但未通过git commit
提交,则sphinx-multiversion构建将失败。
在sphinx-multiversion的git.py模块中:
def copy_tree(gitroot, src, dst, reference, sourcepath="."):
with tempfile.SpooledTemporaryFile() as fp:
cmd = (
"git",
"archive",
"--format",
"tar",
reference.commit,
"--",
sourcepath,
)
subprocess.check_call(cmd, cwd=gitroot, stdout=fp)
fp.seek(0)
with tarfile.TarFile(fileobj=fp) as tarfp:
tarfp.extractall(dst)
在sphinx-multiversion的main.py中使用:
git.copy_tree(str(gitroot), gitroot.as_uri(), repopath, gitref)
一旦我git add
和git commit
可下载的文件,构建就能完美无误地进行,没有错误。
英文:
Apparently sphinx-multiversion archives the files via commit hashes, hence if the changes are made locally and not committed via git commit
, the sphinx-multiversion build will fail.
In sphinx-multiversion's git.py module:
def copy_tree(gitroot, src, dst, reference, sourcepath="."):
with tempfile.SpooledTemporaryFile() as fp:
cmd = (
"git",
"archive",
"--format",
"tar",
reference.commit,
"--",
sourcepath,
)
subprocess.check_call(cmd, cwd=gitroot, stdout=fp)
fp.seek(0)
with tarfile.TarFile(fileobj=fp) as tarfp:
tarfp.extractall(dst)
Used in sphinx-multiversion's main.py:
git.copy_tree(str(gitroot), gitroot.as_uri(), repopath, gitref)
Once I git add
and git commit
the downloadable file, the build works perfectly without errors.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论