Skip to content

Release v2.4.0

Compare
Choose a tag to compare
@rsokl rsokl released this 28 Aug 02:51
· 2 commits to master since this release
7e08197

Thanks to @AntoineD for providing the main improvements for this release, and to those who commented in #38 to shed light on the issues fixed by this release.

This release contains compatibility-breaking changes/fixes for the google_with_merge, numpy_with_merge, and numpy_napoleon_with_merge styles.

Specifically, the merging behavior was changed such that only those docstring sections that contain <name> : <description> style lists (e.g. the Parameters or Args sections) will be merged. Thus sections like Notes will no longer be included in the merging process.

What Does This Fix?

Compounding, repeated sections via multiple-inheritance

Prior to this release, using these styles with multiple inheritance created multiply-repeated inherited sections (see #38). E.g.

class Parent(metaclass=DocInheritMeta(style="numpy_with_merge")):
    """Parent.

    Notes
    -----
    Blah
    """
    pass


class Child1(Parent):
    """Child1. 

    Methods
    -------
    meth: does something
    """
    pass


class Child2(Parent):
    """Child 2.

    Methods
    -------
    blah : does not much
    """


class GrandChild(Child1, Child2):
    """Grand Child."""
    pass

would produce the following docstring for GrandChild

Grand Child.

Methods
-------
blah : does not much
meth: does something

Notes
-----
Blah
Blah
Blah
Blah

Given the changes introduced in v2.4.0, the docstring for GrandChild will now be

Grand Child.

Methods
-------
blah : does not much
meth: does something

Notes
-----
Blah

De-duplicating repeated parameters

Before:

class Parent(metaclass=DocInheritMeta(style="numpy_with_merge")):
    """Parent.

    Attributes
    ----------
    x : int
    y : int
    """
    pass


class Child(Parent):
    """Child.
    
    Attributes
    ----------
    y : float
    z : float
    """
    pass

the docstring of Child would be:

Child.

Attributes
----------
x : int
y : int
y : float
z : float

in v2.4.0, it will be:

Child.

Attributes
----------
x : int
y : float
z : float

Docstring sections included in merging:

  • Attributes
  • Parameters
  • Methods
  • Other Parameters
  • Args
  • Arguments
  • Keyword Args
  • Keyword Arguments