簡體   English   中英

交叉引用由 Jupyter 筆記本中 Sphinx 的自動模塊指令生成的 Python function

[英]Cross reference a Python function generated by Sphinx's automodule directive from Jupyter notebook

使用Sphinx 的 automodule指令,我正在為我的模塊中的所有函數從它們各自的文檔字符串創建一個 API 文檔。 相應的.rst 文件僅包含以下幾行:

API Reference
=============
.. automodule:: pkg_name.module_name
   :members:
   :undoc-members:
   :show-inheritance:

我還使用nbSphinx將 Jupyter 筆記本集成到文檔中。

如何從 Jupyter 筆記本中的 markdown 單元交叉引用由 automodule 指令創建的 function?

誠然,這有點笨拙,但我就是這樣做的: https://nbsphinx.readthedocs.io/en/0.8.2/markdown-cells.html#Links-to-Domain-Objects

換句話說:

如果您的.rst文件名為api_reference.rst ,您可以鏈接到自動生成的 function 文檔,如下所示:

[my_function()](api_reference.rst#pkg_name.module_name.my_function)

如果您不知道在#之后到底要放什么,您可以查看 function 文檔的自動生成的永久鏈接。 重要的是您使用.rst (即源文件的擴展名)而不是.html (即生成的 output 文件的擴展名)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM