我对Python还是很陌生,因此使用了Google(here)的样式指南来获得简洁美观的代码。 现在,我遇到了一个问题,我想根据这些注释为方法和模块创建一个文档,并且发现Sphinx显然是用于该工具的工具。
我进一步发现,可以使用Google Python样式指南,将Sphinx的以下扩展名用于生成文档: https://github.com/google/styleguide/blob/gh-pages/pyguide.md
但是我失败了两点:
下面您可以找到我的一种方法(仅注释),我正在尝试为其生成文档:
def _get_lifecycle_environments(self: object) -> dict:
"""Gets all lifecycle environments
Gets all lifecycle environment from the Satellite server
Args:
Returns:
dict: The name and IDs of all lifecycle environments of the Satellite server. If there are no lifecycle
environments an empty dictionary is returned.
Example of a dict with lifecycle environments and their IDs:
{
'Library': 1,
'lce-default-dev': 2,
'lce-default-prod': 3,
'lce-default-test': 4
}
Raises:
RuntimeError: If the API call fails for some reason
KeyError: If the expected key 'results' is not in the result
KeyError: If the expected key 'name' is not in the result of a lifecycle environment or is None
TypeError: If the expected key 'name' is not a string
KeyError: If the expected key 'id' is not in the result of a lifecycle environment or is None
TypeError: If the expected key 'id' is not a integer
"""