Skip to content

Intersphinx looks for implementation modules #178

@crusaderky

Description

@crusaderky

In my project I have:
mymod.py:

class MyCache(cachetools.LRUCache): ...

mymod.rst:

.. autoclass:: mymod.MyCache
   :members:
   :undoc-members:
   :show-inheritance:

sphinx-build -W fails with:

mymod.py:docstring of mymod.MyCache:1: WARNING: 
py:class reference target not found: cachetools.lru.LRUCache

The problem is that, in objects.inv, the object appears (correctly) under its public module, but LRUCache.__module__ points to the implementation module:

$ python -m sphinx.ext.intersphinx https://cachetools.readthedocs.io/en/latest/objects.inv| grep LRUCache
        cachetools.LRUCache                      index.html#cachetools.LRUCache

Workaround

In conf.py:

import cachetools
cachetools.LRUCache.__module__ = "cachetools"

Solution

The __module__ hack above should be in cachetools.__init__.

External references

This issue is very common. Here's the exact same problem in two other projects:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions