【发布时间】:2026-01-22 21:55:01
【问题描述】:
我有一些在 python 中使用元类的代码。但是当 sphinx autodoc 运行时,它会给出错误:
WARNING: py:class reference target not found: type
错误发生在自动生成的 .rst 文件的一行中:
.. automodule:: API.list.blockList
:members: # this is the line in error
:show-inheritance:
blockList 扩展了 API.list.list,其中 \__metaclass__ 设置为我的元类。
据我所知,sphinx 并不认为内置类型类存在。我尝试导入内置类型以使 sphinx 意识到它的存在,但没有奏效。
如果我从 API.list.list 中删除元类分配,并从代码中删除元类,那么 sphinx 就可以正常工作。
【问题讨论】:
-
你能提供一个触发这个的最小例子吗?
标签: python python-sphinx metaclass autodoc