我正在尝试将外部 API 的交叉引用添加到我的文档中,但我面临三种不同的行为。
我将 sphinx(1.3.1) 与 Python(2.7.3) 一起使用,我的 intersphinx 映射配置为:
{
'python': ('https://docs.python.org/2.7', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'cv2' : ('http://docs.opencv.org/2.4/', None),
'h5py' : ('http://docs.h5py.org/en/latest/', None)
}
我很容易用 :class:`numpy.ndarray`
或 :func:`numpy.array`
编写对 numpy API 的交叉引用,这给了我,正如预期的那样,类似于 numpy.ndarray .
但是,使用 h5py,生成链接的唯一方法是省略模块名称。例如,:class:`Group`
(或 :class:`h5py:Group`
)给我 Group但是 :class:`h5py.Group`
无法生成链接。
最后,我找不到编写对 OpenCV API 的有效交叉引用的方法,这些似乎都不起作用:
:func:`cv2.convertScaleAbs`
:func:`cv2:cv2.convertScaleAbs`
:func:`cv2:convertScaleAbs`
:func:`convertScaleAbs`
如何正确编写对外部 API 的交叉引用,或配置 intersphinx,以在 numpy 的情况下生成链接?
最佳答案
除了@gall 的详细回答,我发现intersphinx
也可以作为模块运行:
python -m sphinx.ext.intersphinx 'http://python-eve.org/objects.inv'
这会输出格式良好的信息。供引用:https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/intersphinx.py#L390
关于python - 如何使用 intersphinx 正确编写对外部文档的交叉引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30939867/