Skip to content

Not showing docs when PyO3 registers a struct with a different name #830

Description

@elbaro

My PyO3 module exposes a Rust struct in two places:

# mylib.SyncConn
m.add_class::<SyncConn>()?;

# mylib.sync.Conn
let sync = PyModule::new(py, "sync")?;
sync.add("Conn", py.get_type::<SyncConn>())?;
m.add_submodule(&sync)?;

pdoc correctly shows the class members of SyncConn not sync.Conn:

Image

As a workaround, I manually assigned an instance of pdoc.doc.Class to the other.
This works if I want to show the full class members in both places, but if I want to customize them differently, I cannot deepcopy pdoc.doc.Class.

all_modules["pyro_mysql.sync"].members["Conn"] = copy.deepcopy(
        all_modules["pyro_mysql"].members["SyncConn"]
    )

all_modules["pyro_mysql"].members[
    "SyncConn"
].docstring = "See `pyro_mysql.sync.Conn`."
all_modules["pyro_mysql"].members["SyncConn"].own_members = []
all_modules["pyro_mysql"].members["SyncConn"].methods = []
all_modules["pyro_mysql"].members["SyncConn"].staticmembers = []
all_modules["pyro_mysql"].members["SyncConn"].classmembers = []

System Information

pdoc: 15.0.4
Python: 3.14.0rc2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions