I am trying to create a versions drop-down in Sphinx by adding a _templates/versions.html
file. Although when I make html
, I see the branch name in my local index.html file. Used the code for versions.html from this stackoverflow post.
Problems I am facing:
When I click the
main
branch link from the local index.html drop-down, it redirects tofile:///main/
. Not sure if this is the expected behavior and if it works fine when I push the code to origin.When I commit my code to Git, I am getting below TypeError. Although my branch is pointing to HEAD.
On my Github repo, the latest commit hash is showing: 4549ac9
.
$ git log --all --oneline
4549ac9 (HEAD -> main, origin/main, origin/dev, origin/HEAD, dev) added yaml
46b2373 initial changes
9ff28c9 Initial commit
Error trace from Readthedocs build: (Not sure what should HEAD point to in my case & how to fix this)
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: