Sphinx automodule: how to reference classes in same module?

后端 未结 2 1726
误落风尘
误落风尘 2021-02-05 02:53

I am trying to use the sphinx autodoc extension and specifically the automodule directive to automatically generate documentation for django app I am working on. Th

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 03:23

    Don't know if I understand the problem but this works flawlessly to me with autodoc, as per Cross-referencing Python objects

    class FlowDirection(GeneralTable):
        '''
        Heat Flow Direction
    
        :cvar int id: database primary key
        :cvar unicode name: name 
        '''
        def __repr__(self):
            return u''.format(
                    self.name, hex(id(self))).encode('utf-8')
    
        def __unicode__(self):
            return self.name
    
    class AirCavityRes(GeneralTable):
        '''
        Air Cavity :term:`thermal resistance`
    
        :cvar flow_direction: heat flow direction
            (see :class:`FlowDirection`)
        :cvar int id: database primary key
        :cvar int if_fd: database foreign key to :class:`FlowDirection`
        :cvar float res: :term:`thermal resistance`
        :cvar float thick: thickness
        '''
        def __repr__(self):
            return u''.format(
                    self.res, hex(id(self)))
    

提交回复
热议问题