从第三方包继承时,Sphinx和Numpydoc抛出解析错误

2024-09-23 05:05:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用sphinx和numpydoc来记录我的代码,但是到目前为止还没有成功。当我试图make html时,我得到了一个非常令人困惑的错误:


Exception occurred:
  File "/Users/micromegas/anaconda3/envs/sphinx4/lib/python3.7/site-packages/numpydoc/docscrape.py", line 330, in _parse_see_also
    raise ParseError("%s is not a item name" % line)
numpydoc.docscrape.ParseError: order, __len__  which are identical is not a item name in 'Returns the number of nodes in the graph.\n\nReturns\n-------\nnnodes : int\n    The number of nodes in the graph.\n\nSee Also\n--------\norder, __len__  which are identical\n\nExamples\n--------\n>>> G = nx.path_graph(3)  # or DiGraph, MultiGraph, MultiDiGraph, etc\n>>> len(G)\n3'
The full traceback has been saved in /var/folders/kx/fc27k_8n52qcd8cylq98z7ph0000gn/T/sphinx-err-f9d7ufke.log, if you want to report the issue to the developers.


sphinx无法解析的docstring来自一个依赖项,我的代码从该依赖项继承了一个类。但是这个依赖关系使用的是sphinx和numpy docstyle本身(https://github.com/networkx/networkx)。因此,我可以通过不从特定类继承来消除错误,但这不是真正的解决方案。你知道吗

我试图修改conf,使之适应第三方软件包。没有成功。也许我可以阻止斯芬克斯把它写进医生的档案里?Idk。。。。你知道吗

有人知道我可以试试吗?你知道吗

非常感谢!你知道吗


Tags: the代码nameinlenis错误sphinx