Skip to content

Commit

Permalink
Fixed numpy-section delimiter length. docinherit now preserves functi…
Browse files Browse the repository at this point in the history
…on sigs.
  • Loading branch information
rsokl committed Sep 13, 2016
1 parent 70c5d96 commit 3836a64
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 2.0.1
- Numpy-style section delimiters was fixed so that they are the appropriate length, and thus compatible with the numpy-style for sphinx.

- `doc_inherit` was refactored so that the signature of the decorated function is now preserved in Python(< 3.4). This was not an issue for newer versions of Python.

### 2.0.0
- A decorator, `doc_inherit` is now available for mediating docstring inheritance for a single function/method.property/etc.

Expand All @@ -12,4 +17,4 @@

- Styles need only be logged in `custom_inherit.style_store.__all__` for the style to become available for use.

- The "numpy" inheritance style was updated to accommodate for situations in which method docstrings contain both "Raises" and "Returns"/"Yields" sections.
- The "numpy" inheritance style was updated to accommodate for situations in which method docstrings contain both "Raises" and "Returns"/"Yields" sections.
2 changes: 1 addition & 1 deletion custom_inherit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


__all__ = ["DocInheritMeta", "doc_inherit", "store", "add_style", "remove_style"]
__version__ = "2.0.0"
__version__ = "2.0.1"


class _Store(dict):
Expand Down
9 changes: 3 additions & 6 deletions custom_inherit/decorator_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from functools import wraps
try:
basestring
except NameError:
Expand All @@ -8,6 +7,7 @@

__all__ = ["DocInheritDecorator"]


class DocInheritDecorator(object):
""" A decorator that merges provided parent docstring with the docstring of the decorated
function/method/property.
Expand Down Expand Up @@ -41,11 +41,8 @@ def __call__(self, func):
FunctionType
The decorated function/method/property whose docstring is given by
DocInheritDecorator.doc_merger(prnt_attr_doc, child_doc)"""
@wraps(func)
def wrapped(*args, **kwargs):
return func(*args, **kwargs)
wrapped.__doc__ = self.doc_merger(self.prnt_doc, func.__doc__)
return wrapped
func.__doc__ = self.doc_merger(self.prnt_doc, func.__doc__)
return func

@staticmethod
def doc_merger(prnt_attr_doc, child_doc):
Expand Down
2 changes: 1 addition & 1 deletion custom_inherit/doc_parse_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def merge_section(key, prnt_sec, child_sec):
if key == "Short Summary":
header = ''
else:
header = "\n".join((key, "-".join("" for i in range(len(key))), ""))
header = "\n".join((key, "".join("-" for i in range(len(key))), ""))

if child_sec is None:
body = prnt_sec
Expand Down

0 comments on commit 3836a64

Please sign in to comment.