我正在尝试使用sphinx编写API文档 我从模型开始,但无法正确记录属性
以下是一个例子:
class Incoterm(AuditedModel(updatable=True), ModelBase, db.Model):
"""Incoterm Definition
Args:
AuditedModel (class): Audit class
ModelBase (class): Model base class
db (class): SQLAlchemy instance
Attributes:
abbreviation (String): an abbreviation
full_name (String): the full name
group (String): which group it belong
"""
abbreviation = Column(String(3), nullable=False)
full_name = Column(String(128), nullable=False)
group = Column(String(1), nullable=False)
使用$ sphinx-apidoc -o . ..
和$ make html
生成的文档两次显示属性,并在没有定义的情况下显示类继承
我还尝试在变量#: str: an string
前面插入注释,如sphinx examples中所述,但得到了相同的结果
我发现的一个解决方法是.rst文件中的注释:undoc-members:
。
有更好的方法来实现这一点吗?我错过了什么
如果像这样记录类属性,问题很可能会消失
参考: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute 向下滚动到
class Foo
示例相关问题 更多 >
编程相关推荐