[英]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 嗎?
謝謝
其實我想我找到了這個問題的答案。 原來我的 sphinx 使用的是 python 2.7 站點包。 這有幫助: 如何強制 Sphinx 使用 Python 3.x 解釋器
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.