python > 3.5 文档字符串的 Sphinx autodoc 扩展因函数参数类型而不起作用
Sphinx autodoc extension for python > 3.5 docstrings not working because of function argument types
我一直在尝试让 autodoc 自动记录我的 python 3.7 模块。我需要记录的唯一文件是单个模块中的 init.py 文件。该文件仅包含函数,并具有 Sphinx 格式的文档字符串。到目前为止,一切都很好。
但是,我的函数会注明其参数类型,例如:
def func1(filepaths: list):
...
def log_custom_hyperparameter(model, param_name: str, param_value):
...
这是在抛弃 autodoc。我收到以下错误:
WARNING: autodoc: failed to import module u'<my_module>'; the following exception was raised:
Traceback (most recent call last):
File "/Users/manjotpahwa/Library/Python/2.7/lib/python/site-packages/sphinx/ext/autodoc/importer.py", line 154, in import_module
__import__(modname)
File "/Users/manjotpahwa/<path to file>/__init__.py", line 9
def log_code_files(filepaths: list):
^
SyntaxError: invalid syntax
autodoc 不支持解析 python 个 > python 3.5 的文件吗?
谢谢
其实我想我找到了这个问题的答案。原来我的狮身人面像使用的是 python 2.7 站点包。
这有助于:
How to force Sphinx to use Python 3.x interpreter
我一直在尝试让 autodoc 自动记录我的 python 3.7 模块。我需要记录的唯一文件是单个模块中的 init.py 文件。该文件仅包含函数,并具有 Sphinx 格式的文档字符串。到目前为止,一切都很好。 但是,我的函数会注明其参数类型,例如:
def func1(filepaths: list):
...
def log_custom_hyperparameter(model, param_name: str, param_value):
...
这是在抛弃 autodoc。我收到以下错误:
WARNING: autodoc: failed to import module u'<my_module>'; the following exception was raised:
Traceback (most recent call last):
File "/Users/manjotpahwa/Library/Python/2.7/lib/python/site-packages/sphinx/ext/autodoc/importer.py", line 154, in import_module
__import__(modname)
File "/Users/manjotpahwa/<path to file>/__init__.py", line 9
def log_code_files(filepaths: list):
^
SyntaxError: invalid syntax
autodoc 不支持解析 python 个 > python 3.5 的文件吗?
谢谢
其实我想我找到了这个问题的答案。原来我的狮身人面像使用的是 python 2.7 站点包。 这有助于: How to force Sphinx to use Python 3.x interpreter