Skip to content

Reference from private module to other private module is not rendered correctly #548

@kasium

Description

@kasium

I have a method in a private module which references in a type hint another class from another private module.
Both are then reexported in the __init__ file.

autodoc can render the references as expected: Return type: Foo. autoapi however cannot do that: Return type: project._other.Foo

project/__init__

from __future__ import annotations

from project._other import Foo
from project._private import create_foo

__all__ = ["Foo", "create_foo"]

_project/other.py

class Foo:
    """A simple Foo class."""

_project/private.py

from project._other import Foo


def create_foo() -> Foo:
    """Factory function to create a Foo instance."""
    return Foo()

project_docs/conf.py

from __future__ import annotations

project = "Project"
extensions = [
    "sphinx.ext.napoleon",
    "autoapi.extension",
    "sphinx.ext.autodoc",
]
autoapi_dirs = ["../project"]
autoapi_root = "api"
autodoc_typehints = "description"
autoapi_options = [
    "members",
    "undoc-members",
    "show-inheritance",
    "show-module-summary",
    "imported-members",
    "special-members",
]
autoapi_ignore = ["_[^_].*"]
autoapi_add_toctree_entry = False
autoapi_keep_files = True

```

_project_docs/index.rst_
```rst
Project
=======

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   api/project/index

.. automodule:: project
    :members:
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions