2016-05-23 41 views
2

這裏的主要問題是在哪裏(如果)TensorFlow有一個objects.inv,但是如何實際使用它的例子會很好。如何在Tensorflow和numpydoc中使用intersphinx?

例如,我現在有以下文檔字符串:

""" 
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文檔?

+0

我不認爲你可以這樣做。 TensorFlow文檔是用Markdown編寫的,Sphinx根本不參與。 – mzjn

回答

3

mzjn is right - 如果文檔不是獅身人面像生成的,將不會有objects.inv文件找到。

但是,您可以創建自己的objects.inv以使用Tensorflow。我剛剛發佈了一個Python包,讓我做這件事,連同how-to instructions。簡而言之:

  1. 創建一個新的文本文件。

  2. 添加獅身人面像頭:

    # 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}

{name}通常是完全限定的對象名稱。你可以create your own Sphinx domain,但是如果碰撞的可能性很小,你可以使用python作爲{domain}和合適的Python {role}function,method等)。 {priority}幾乎總是1{relative uri}與您將在conf.pyintersphinx_mapping參數中包含的基本URI相關。 {displayname}通常也是完全限定的對象名稱。

  1. 使用sphobjinv將文件編碼爲objects.inv

  2. 上傳到一個方便,無障礙的位置。

  3. 配置intersphinx:

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

應該這樣做。勞動強度很大,不得不自己複合文件,但如果只是在需要時添加它們,它應該不會太壞。