相关疑难解决方法(0)

如何在Python中记录模块常量?

我有一个模块,errors.py其中定义了几个全局常量(注意:我知道Python没有常量,但我已经使用UPPERCASE按惯例定义了它们).

"""Indicates some unknown error."""
API_ERROR = 1

"""Indicates that the request was bad in some way."""
BAD_REQUEST = 2

"""Indicates that the request is missing required parameters."""
MISSING_PARAMS = 3
Run Code Online (Sandbox Code Playgroud)

使用reStructuredText如何记录这些常量?正如你所看到的,我已经在他们上面列出了一个文档字符串,但我没有找到任何表明这样做的文档,我只是猜测它.

python restructuredtext python-sphinx

47
推荐指数
5
解决办法
2万
查看次数

如何在sphinx doc中显示实例属性?

有没有办法如何在sphinx文档中自动显示变量var1var2及其init-values?

class MyClass:
    """    
    Description for class
    """

    def __init__(self, par1, par2):
       self.var1 = par1 * 2
       self.var2 = par2 * 2

    def method(self):
       pass
Run Code Online (Sandbox Code Playgroud)

python documentation python-sphinx

36
推荐指数
1
解决办法
2万
查看次数