我一直在尝试记录我的蒙戈引擎 http://mongoengine-odm.readthedocs.org/基于应用程序,但我在文档类上记录属性时遇到问题。
我采取的正确语法如下:
class Asset(Document):
#: This is the URI of the document
uri = StringField()
我尝试了各种方法来记录我发现的这些属性,甚至添加了一个不是 MongoEngine 字段的属性,只是为了确保这不是问题:
class Asset(Document):
"""
The representation of a file uploaded into the data store.
"""
#: This is a test attribute.
foo = 'bar'
"""baz?"""
#: This is a URI.
uri = StringField(required=True)
"""This is a URI """
我已经尝试了相应的指令的各种组合.rst
文件。目前它看起来像这样:
.. currentmodule:: mymodule.asset
.. autoclass:: Asset
.. autoattribute:: Asset.foo
.. autoattribute:: Asset.uri
输出不太令人满意:foo
属性根本没有显示任何文档,并且 uri 字段具有 MongoEngine 的“A unicode string field”。 (该文档的StringField
类)作为文档。此外,属性文档也不放在类的“下方”(与 automodule + :members: 一样,它输出所有字段及其 MongoEngine 描述)
我错过了 Sphinx 扩展吗?或者我搞砸了语法?
要将类的成员添加到文档中,请使用:members:
option:
.. autoclass:: Asset
:members:
Without :members:
, 只有类文档字符串 http://sphinx-doc.org/ext/autodoc.html#directive-autoclass已插入。
另请参阅autodoc_default_flags http://sphinx-doc.org/ext/autodoc.html#confval-autodoc_default_flags配置选项。
您可以获得与上面相同的结果autoattribute
并且没有:members:
(注意缩进):
.. autoclass:: Asset
.. autoattribute:: foo
.. autoattribute:: uri
我无法重现该问题uri
使用 StringField 中的文档字符串记录属性。
我正在使用 Sphinx 1.2.2。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)