sphinx-doc / sphinx-doc/sphinx

Incorrect `objects.inv` produced for `singlehtml`

Open
#10,106 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:singlehtml extensions:intersphinx type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

I haven't been able to get Intersphinx links to objects in Hyrule to work. I think this is because Hyrule uses the singlehtml builder and the generated objects.inv in this case has spurious anchors.

How to Reproduce
#!/bin/sh
mkdir testp
cd testp
mkdir mylib
printf 'def foo():\n "my docstring"\n return 1\n' >mylib/__init__.py
printf '.. automodule:: mylib\n  :members:\n' >index.rst
echo 'extensions = ["sphinx.ext.autodoc"]' >conf.py
mkdir build
PYTHONPATH=. sphinx-build . _build -b singlehtml
python3 -msphinx.ext.intersphinx _build/objects.inv
Expected behavior

I expected index.html#module-mylib in the output, as with the html builder, instead of index.html#document-index#module-mylib.

Your project

See the shell script above.

Screenshots

No response

OS

Ubuntu 21.10

Python version

3.9.7

Sphinx version

4.3.2

Sphinx extensions

sphinx.ext.autodoc

Extra tools

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the shell reproduction with Sphinx's singlehtml builder and inspect the generated _build/objects.inv using sphinx.ext.intersphinx. Trace how the singlehtml output records the module anchor, then verify that the inventory uses index.html#module-mylib rather than index.html#document-index#module-mylib.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.