如何将intersphinx与Tensorflow和numpydoc一起使用?

时间:2016-05-23 10:30:00

标签: tensorflow python-sphinx

这里的主要问题是(如果)TensorFlow有objects.inv,但是如何实际使用它会很好。

例如,我目前有以下文档字符串:

"""
Load the weights of a model stored in saver.

Parameters
----------
checkpoint_dir : str
    The directory of checkpoints.
sess : tf.Session
    A Session to use to restore the parameters.
saver : tf.train.Saver
"""

如何使用intershinx自动将对象链接到TensorFlow文档?

1 个答案:

答案 0 :(得分:2)

mzjn is right - 如果文档不是Sphinx生成的,则无法找到objects.inv个文件。

但是,您可以使用Tensorflow创建自己的objects.inv。我刚刚发布了一个Python包,让我一起做这个事情,以及how-to instructions。简言之:

  1. 创建新的文本文件。

  2. 添加Sphinx标题:

    # Sphinx inventory version 2
      # Project: <project name>
      # Version: <full version number>
      # The remainder of this file is compressed using zlib.

  3. 为您希望包含在广告资源

    中的每个对象添加数据行

    {name} {domain}:{role} {priority} {relative uri} {displayname}

  4. {name}通常是完全限定的对象名称。您可以create your own Sphinx domain,但如果碰撞几率很小,您可以使用python作为{domain}和合适的Python {role}functionmethod等)。 {priority}几乎总是1{relative uri}相对于您在intersphinx_mapping conf.py参数中包含的基URI。 {displayname}通常也是完全限定的对象名称。

    1. 使用sphobjinv将文件编码为objects.inv

    2. 上传到方便,易于访问的位置。

    3. 配置intersphinx:

      intersphinx_mapping = {'tensorflow' = ('uri/to/tensorflow/docs/base', 'uri/to/objects.inv')}

    4. 应该这样做。有点劳动密集,不得不自己合成文件,但如果你只是根据需要添加它们,它就不会太糟糕。

相关问题