我正在使用Sphinx(make HTML)从其函数的reStructuredText文档字符串自动生成Python 3模块的HTML文档.到目前为止,生成的HTML文档看起来很好,但函数签名的参数类型(在源代码中作为PEP484类型提示给出)未正确显示.
例如,这是我的一个函数的Sphinx生成的HTML文档的一些示例输出:
static parse_from_file(filename: str) ? list
Parses stuff from a text file.
Parameters: filename – the filepath of a textfile to be parsed
Returns: list of parsed elements
Run Code Online (Sandbox Code Playgroud)
这就是我期望的样子:
static parse_from_file(filename)
Parses stuff from a text file.
Parameters: filename (str) – the filepath of a textfile to be parsed
Returns: list of parsed elements
Return type: list
Run Code Online (Sandbox Code Playgroud)
这就是Python代码的实际外观:
def parse_from_file(filename: str) -> list:
"""Parses stuff from a text file.
:param filename: the filepath of a …Run Code Online (Sandbox Code Playgroud)