使用Google样式指南生成Python Sphinx文档

时间:2018-11-24 16:39:04

标签: python-3.x python-sphinx documentation-generation

我对Python还是很陌生,因此使用了Google(here)的样式指南来获得简洁美观的代码。 现在,我遇到了一个问题,我想根据这些注释为方法和模块创建一个文档,并且发现Sphinx显然是用于该工具的工具。

我进一步发现,可以使用Google Python样式指南,将Sphinx的以下扩展名用于生成文档: https://github.com/google/styleguide/blob/gh-pages/pyguide.md

但是我失败了两点:

  1. 如何包含此扩展程序才能正常工作?
  2. 我必须如何调用Sphinx才能获得有关我的方法和模块的完整文档?
  3. (可选)是否可以将其集成到PyCharm(专业)中?

下面您可以找到我的一种方法(仅注释),我正在尝试为其生成文档:

    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
    """

0 个答案:

没有答案