SublimeAutoDocstring icon indicating copy to clipboard operation
SublimeAutoDocstring copied to clipboard

Google Style class vs instance attributes

Open jaune-rouge opened this issue 7 years ago • 1 comments

Hi, this very well may just be my inexperience with docstrings, but when creating class with both static (class) and instance variables they all get lumped together under attributes. Should these be distinguished in the docstring?

Example of what I get:

class foo():
  """Summary
  Attributes:
      a (int): Description
      b (int): Description
  """
  
  a = 3
  def __init__(self):
    """Summary
    """
    self.b = 2

jaune-rouge avatar Sep 28 '17 02:09 jaune-rouge

Interesting - I hadn't considered this. Since class attributes exist in a different namespace (with all the differences that entails), I imagine there's merit to keeping them separate from instance attributes. The napoleon documentation doesn't call this out, so I'm not sure how tools like sphinx would handle a section named "Class Attributes". I'll play with this when I get some free time. If anyone feels so inclined, feel free to poke around and share what you learn :)

KristoforMaynard avatar Sep 28 '17 15:09 KristoforMaynard