Sphinx无法使用TypeError构建项目:HEAD是一个分离的符号引用



我正试图通过添加_templates/versions.html文件在Sphinx中创建一个版本下拉列表。尽管当我make html时,我在本地index.html文件中看到了分支名称。使用了这篇stackoverflow文章中versions.html的代码。

我面临的问题:

  1. 当我从本地index.html下拉列表中单击main分支链接时,它会重定向到file:///main/。不确定这是否是预期的行为,以及当我将代码推送到原点时它是否正常工作。

  2. 当我将代码提交到Git时,我得到的是TypeError以下。虽然我的树枝指向头。

在我的Github repo上,最新的提交哈希显示为:4549ac9

$ git log --all --oneline
4549ac9 (HEAD -> main, origin/main, origin/dev, origin/HEAD, dev) added yaml
46b2373 initial changes
9ff28c9 Initial commit

Readthedocs构建的错误跟踪:(不确定HEAD在我的情况下应该指向什么以及如何修复此问题(

Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/sphinx/config.py", line 347, in eval_config_file
exec(code, namespace)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/checkouts/latest/docs/conf.py", line 86, in <module>
current_version = repo.active_branch.name
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/git/repo/base.py", line 797, in active_branch
return self.head.reference
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/git/refs/symbolic.py", line 294, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '4549ac97308ea4fe0fc2b8def2ba509ce536db29'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/sphinx/cmd/build.py", line 272, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/sphinx/application.py", line 201, in __init__
self.config = Config.read(self.confdir, confoverrides or {}, self.tags)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/sphinx/config.py", line 169, in read
namespace = eval_config_file(filename, tags)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-ver/envs/latest/lib/python3.9/site-packages/sphinx/config.py", line 360, in eval_config_file
raise ConfigError(msg % traceback.format_exc()) from exc
sphinx.errors.ConfigError: There is a programmable error in your configuration file:

您似乎在conf.py文件中使用gitpython,但在行失败

current_version = repo.active_branch.name

我在gitpython上发现了一个打开的问题https://github.com/gitpython-developers/GitPython/issues/633谈到这个问题。我建议你读一下那期,看看是否有什么有用的。否则,你可能会问他们你的具体问题。

这似乎不是与Sphinx或Read the Docs有关的问题,而是与您对gitpython的配置和使用有关的问题。

相关内容

  • 没有找到相关文章

最新更新