Custom Inherit Versions Save

A Python package that provides tools for inheriting docstrings in customizable ways.

v2.4.1

1 year ago

v2.4.0

2 years ago

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

v2.3.2

2 years ago

Fixes a bug to ensure that DocInheritMeta returns a distinct metaclass instead of mutating it.

v2.3.1

3 years ago

Previously, the Methods section in a NumPy-style docstring was not recognized

New behavior:

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

        Methods
        -------
        meth
        """
        pass

    class Child(Parent):
        """Child summary.

        Attributes
        ----------
        a: hello
        """
        pass

Child will have the docstring

Child summary.

Attributes
----------
a: hello

Methods
-------
 meth