Cea*_*sta 7 python python-sphinx
我有两个文件,foo.py和bar.py.
foo.py 包含:
import bar
class B():
a = bar.A
Run Code Online (Sandbox Code Playgroud)
bar.py 包含:
class A():
pass
Run Code Online (Sandbox Code Playgroud)
我正在docs/index.rst通过以下方式生成这些文档:
.. automodule:: bar
:members:
:undoc-members:
.. automodule:: foo
:members:
:undoc-members:
Run Code Online (Sandbox Code Playgroud)
现在,当我build html使用nit-picky flag(-n)运行时,我得到以下内容,并发出警告WARNING: py:class reference target not found: A:
(env)bash-3.2$ make html
sphinx-build -b html -d _build/doctrees -n . _build/html
Running Sphinx v1.2.3
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
/Users/caesarbautista/Desktop/test_docs/docs/index.rst:12: WARNING: py:class reference target not found: A
writing additional files... genindex py-modindex search
copying static files... done
copying extra files... done
dumping search index... done
dumping object inventory... done
build succeeded, 1 warning.
Build finished. The HTML pages are in _build/html.
Run Code Online (Sandbox Code Playgroud)
我该如何修复此警告?
到目前为止,我已经尝试搜索谷歌和文档没有运气.它也与A导入方式无关.我试过from bar import A没有成功.错误消息非常不透明.
我可以在这里找到我设置的测试项目的副本.
在你的代码中你有
class B():
a = bar.A
Run Code Online (Sandbox Code Playgroud)
您必须使用实例化而不是类别名。a = bar.A当我替换为时警告就消失了a = bar.A()