Sphinx中的python属性值基数

时间:2018-11-25 12:44:11

标签: python-sphinx

给出一个这样的类:

from enum import IntEnum
class T(IntEnum):
    a = 0x10
    b = 0x20

在记录此类的属性时,是否可以让Sphinx用十六进制表示形式而不是默认的十进制形式记录枚举?

编辑

我尝试使用autodoc-process-signature,除了属性引用中断并且不再可以交叉引用属性之外,该方法行之有效。

我正在这样使用它:

def attribute_hex_render(app, what, name, obj, options, signature, return_annotation):
    if 'TestObject.' in name and what == 'attribute':
        return f" = {obj:#06x}", return_annotation
    return signature, return_annotation #no-op

def setup(app):
    # -- Document attributes in hex
    app.connect('autodoc-process-signature', attribute_hex_render)

0 个答案:

没有答案
相关问题