我有一个我正试图用Sphinx记录的课程。包含以下类的模块(仅显示类的第一部分)
class StructureContainer:
"""
Data structure for describing a collection of Particles
"""
def __init__(self, ptclC=ParticleContainer()):
…
包含在我的sphinx文档中,代码如下:
.. automodule:: structureContainer
:members:
:show-inheritance:
哪个工作正常。但是ptclC的默认值应该是另一个类'ParticleContainer'的默认构造函数。但是在文档中看起来好像是在文档本身中实例化构造函数(抱歉我不能发布图像)
class structureContainer.StructureContainer(ptclC=<particles.ParticleContainer instance at 0x1071ed710>,
如何将对象实例信息排除在HTML文档之外?
答案 0 :(得分:0)
So, to elaborate and perhaps fix your problem as well...
def __init__(self, ptclC=None):
if ptclC is None:
ptclC =ParticleContainer()
The reason I am answering this is because I think Sphinx is, correctly, showing that you're instantiating at function definition time.