'autodoc: workaround when "cannot import module"

The package I want to document with Sphinx contains pure Python modules (ok) + a C/C++ library bind using pybind11. There are a lot of dependencies that can not reasonnably be built on ReadTheDocs!

So on RTD, autodoc can not import my library to extract the docstrings...

My first idea was to generate _build/doctrees locally and use it on RTD. But it contains binary files, heavy to store in the repository: no.

Is there a way to "expand" autodoc directives in RST files? It could produce full text of RST files or a fake static module as a .py...

Thanks in advance for your ideas!

Mathieu



Solution 1:[1]

I wrote a small tool that produces Python code from a compiled Python extension (signatures and docstrings of course).

In the case, it can be useful for others: https://gitlab.com/doc-tools/pydoc-codedoc

(still incomplete of course)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mcourtois