首页 > 解决方案 > 从第三方包继承时,Sphinx 和 Numpydoc 会引发解析错误

问题描述

我正在尝试使用 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 无法解析的这个文档字符串来自我的代码继承类的依赖项。但是这种依赖是使用 Sphinx 和 numpy docstyle 本身(https://github.com/networkx/networkx)。所以我可以通过不从那个特定的类继承来摆脱错误,但这不是一个真正的解决方案。

我试图改变conf.py类似以使其适应第三方包。没有成功。另外,也许我可以阻止狮身人面像将其包含在文档中?想...

有谁知道我可以尝试什么?

标签: pythonpython-sphinxnumpydocsphinx-napoleon

解决方案


推荐阅读