pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Stub file information doesn't seem to be included from `_lib.pyi`

Open jonded94 opened this issue 9 months ago • 4 comments

Package setup

We have some internal namespace package written in Rust & PyO3.

It's organized like this:

pyproject.toml
uv.lock
tests/
  [...]
src/
  [internal namespace]/
    [pkg name]/
      __init__.py
      py.typed
      _lib.so
      _lib.pyi

_lib.so is the shared library built from our Rust code. In our __init__.py, we reference this:

$ cat __init__.py
from ._lib import [ClassA, ClassB, ...]

__all__ = [
    "[ClassA]",
    "[ClassB]",
    ...
]

Problem description

When I now create documentation by calling pdoc [namespace].[pkgname], I'm given this function documentation for example:

Image

(ignore the slightly broken formatting of the docstring, this is because we haven't standardized docstring formats yet 😅 )

As you can see, it contains function signature defaults, all parameters and the docstring. But it entirely misses typing information that is in _lib.pyi.

When I create documentation with pdoc [namespace].[pkgname]._lib, I do see information from the stub file though!

Image

But now, the documentation is limited purely to the _lib submodule. Is there a way to create documentation of the entire package, but also correctly discovering stub files automatically?

System Information

$ pdoc --version
pdoc: 15.0.1
Python: 3.11.9
Platform: Linux-6.13.7-1-MANJARO-x86_64-with-glibc2.41

jonded94 avatar Mar 25 '25 21:03 jonded94

One workaround here is to put your type annotations into __init__.pyi.

mhils avatar Apr 09 '25 07:04 mhils

@mhils is this a use case you are interested in supporting? I've prepared a patch if so.

My use case is similar to OP but with nanobind bindings instead of PyO3.

inventshah avatar Nov 11 '25 18:11 inventshah

If you have a patch please send it, really depends on how much complexity we're adding. :)

mhils avatar Nov 11 '25 18:11 mhils

Opened a PR!

inventshah avatar Nov 11 '25 20:11 inventshah