我正在将一些C代码转换为Python 3,包括通常在原始C代码中作为XML摘要编写的文档。
<see cref="ClassName"/>
元素或
<paramref name="fileName"/>
元素,例如在将其转换为HTML时创建可单击的链接。我想知道我使用的Python ReST docstring格式中是否有类似的东西。
例如,让我们以C方法文档为例:
/// <summary>
/// Reads and returns a <see cref="DummyFile"/> instance from the file with the
/// given <paramref name="fileName"/>.
/// </summary>
/// <param name="fileName">The name of the file to read the data from.</param>
/// <returns>The read <see cref="DummyFile"/> instance.</returns>
public DummyFile LoadDummyFile(string fileName)
{
// Do some dummy file work.
}
在Python中,我将其转换为:
"""
Reads and returns a DummyFile instance from the file with the given file_name.
:param file_name: The name of the file to read the data from.
:param str file_name: The name of the file to read the data from.
:return: The read DummyFile instance.
:rtype: DummyFile
"""
def load_dummy_file(file_name: str) -> DummyFile
# Do some dummy file work.
:rtype
?)
如您所见,我只是以纯文本形式输入了类名和参数名,不知道是否有这样的特殊语法可以在稍后创建web文档时从中创建可单击的链接。