Skip to content

Clarifying inheritance of class documentation in python. #925

Description

@OasisArtisan

Wanted to clarify what the recommendation was for documenting child classes. What should be repeated and what should be referred back to the parent class.

For example, should we do this:

class Fruit:
  """

  Attributes:
    weight: The weight of the fruit in grams.
  """

class Apple(Fruit):
  """

  Attributes:
    weight: The weight of the fruit in grams.
    variety: The variety of the apple from the list ["granny smith", "honey_crisp"]
  """

Or this:

class Fruit:
  """

  Attributes:
    weight: The weight of the fruit in grams.
  """

class Apple:
  """

  Attributes:
    weight: See parent.
    variety: The variety of the apple from the list ["granny smith", "honey_crisp"]
  """

Keep in mind when arguments grow large it would be much harder to maintain the doc strings if they were copied for each child class. But its also more convenient for a user to have it copied.

Appreciate your thoughts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions