我正在使用Sphinx從我的docstrings中生成我的HTML文檔,比如一個好的'Pythonista'。如何鏈接到使用Sphinx的str方法?
我有一個文檔字符串看起來像這樣:
def do_a_thing(text):
'''
Call the ``str.strip()`` method on ``text``. Then do something
else with it.
'''
不過,我希望它鏈接到https://docs.python.org/3/library/stdtypes.html#str.strip,而不是僅僅將所有的等寬字體和代碼塊狀。
我試過幾個途徑:這些工作
:py:func:`str.strip()`
:mod:`str.strip()`
:class:`str.strip()`
:any:`str.strip()`
:doc:`str.strip()`
無 - 或者更準確地說,前四個辦法給我等寬&加粗字體,但它們都沒有實際聯繫的任何地方。而any
指令給我WARNING: 'any' reference target not found: str.strip()
顯然我可以自己建立一個鏈接,但這看起來很嚴重,也可能並不完全是我想要的,因爲當我升級到Python 4時呢?然後,我必須更新我的文檔中的所有鏈接,這很糟糕。
鏈接到str方法的Python文檔的正確方法是什麼?
所以,我已經有了配置,像這樣的intersphinx。我嘗試了'',並且它鏈接到了'https:// docs.python.org/3/docs/ modules.html#tut-packages'。但是,如果我把''放在那裏,就像'https:// docs.python.org/3/library/stdtypes.html# str.lstrip'末尾的內容那樣鏈接我在那裏。 –
我更新了你的具體項目的答案。對於Python,您還可以使用[Python域名](http://www.sphinx-doc.org/en/stable/domains.html#the-python-domain)中的任何指令,其中包括: : py:meth:'str.strip' –
':py:meth:'正是我需要的 - 謝謝! –