4
class Parameters(dict):
     """ Some doc here """
     pass

class System(object):
     Parameter = Parameters
     """ The default parameters attribute builder """

     def __init__(self):
         self.parameters = self.Parameters()

The problem is when i do a autoclass of System with sphinx, the document Parameter will not be what I wrote bellow Parameter = Parameters but will be the full doc of the Parameter class. I do not want that, it is too messy and do not match what my .Parameters attribute is really (can be a Parameters class but also a function, or a dict(a=0,b=1).copy etc...) .

System
======
.. autoclass:: system.System
    :members: __init__,Parameters

The only way I found is to set Parameters to None first and change it at init but it is not convenient for other reasons

class System(object):
    Parameter = None
    """ The default parameters attribute builder """

 def __init__(self):
     if self.Parameters is None:
         self.Parameters = Parameters
     self.parameters = self.Parameters()
bad_coder
  • 11,289
  • 20
  • 44
  • 72
user3240484
  • 209
  • 1
  • 4
  • 1
    When I do this, it creates [this](https://i.imgur.com/ILGy48l.png), which seems like what you want. Also, since it is an attribute, it should really be `parameter = Parameters`, since CamelCase is reserved for class names. – Artyer Jun 19 '17 at 18:06
  • Differing Sphinx versions, maybe? – Valentin Lorentz Jun 22 '17 at 23:33

1 Answers1

1

can it be done, like this ?

class Parameters(dict):
    pass

class System(object):

    def __init__(self, Parameters):
        self.parameters = Parameters


parameters = Parameters()
parameters['x'] = '3.14'
parameters['y'] = '1.618'

system = System(parameters)

print(system.parameters)

{'y': '1.618', 'x': '3.14'}
  • hello, thanks, my problem is only with the sphinx doc render. in my programs the Parameter attribute must be a constructor of parameters defined in subclassing and should not be an argument os 'System'. e.g. : `Parameters = dict(x=3.14, y=1.618).copy` in a System sub-class definition. – user3240484 Jun 30 '17 at 14:25
  • Sorry, got it ! – Elinaldo Monteiro Jun 30 '17 at 18:49