Python Google 文档字符串参考部分

问题描述 投票:0回答:2

有谁知道在遵循谷歌格式的Python文档字符串中包含引用的好方法吗?我正在编写一系列流体属性生成器。我想要一种方法来轻松记录我正在使用的相关性或方程的引用,以便有人可以阅读它们或了解它们来自哪里。我执行了以下操作,但 VS Code 中的格式不正确。有谁知道还有其他方法吗?

def viscosity(self) -> float: 
    """Live oil viscosity, cP    
    
    Return the live oil viscosity, cP.
    Requires pressure and temperature condition to previously be set.

    Args:
        None

    Returns:
        uoil (float): live oil viscosity, cP

    References:
        Fundamental Principles of Reservoir Engineering, B.Towler (2002) Page 23
        Correlations for Fluid Physical Property... Vasquez and Beggs (1980)
    """
    
    pabs = self._pressa  # absolute pressure
    temp = self.temp  # deg F
    oil_api = self.oil_api
python docstring
2个回答
0
投票

您可以使用无序列表来格式化您的参考文献:

def viscosity(self) -> float: 
    """Live oil viscosity, cP    
    
    Return the live oil viscosity, cP.
    Requires pressure and temperature condition to previously be set.

    Args:
        None

    Returns:
        uoil (float): live oil viscosity, cP

    References:
        - Fundamental Principles of Reservoir Engineering, B.Towler (2002) Page 23
        - Correlations for Fluid Physical Property... Vasquez and Beggs (1980)
    """
    pass

在代码提示中,这个无序列表如下所示:


-1
投票

有一个名为 autoDocstring 的 VS Code 扩展,可以帮助生成各种格式的文档字符串。它有一个使用哪个标准的设置,其中包括谷歌。

© www.soinside.com 2019 - 2024. All rights reserved.