diff --git a/python/abess/linear.py b/python/abess/linear.py index c6ac7b726..8c4d0a962 100644 --- a/python/abess/linear.py +++ b/python/abess/linear.py @@ -15,10 +15,24 @@ def fix_docs(cls): # This function is to inherit the docstring from base class # and avoid unnecessary duplications on description. - index = cls.__doc__.find("Examples\n --------\n") - if index != -1: - cls.__doc__ = cls.__doc__[:index] + \ - cls.__bases__[0].__doc__ + cls.__doc__[index:] + title_index = cls.__doc__.find("Parameters\n ----------n") + more_para_index = cls.__doc__.find("Examples\n --------\n") + base_para_index = cls.__bases__[0].__doc__.find("Attributes\n ----------") + if title_index == -1: + title_index = 0 + if more_para_index == -1: + more_para_index = len(cls.__doc__) - 1 + # class title + full_doc = cls.__doc__[:title_index] + # class paras + full_doc = (full_doc + + cls.__bases__[0].__doc__[:base_para_index] + + cls.__doc__[title_index:more_para_index]) + # more info + full_doc = (full_doc + + cls.__doc__[more_para_index:] + + cls.__bases__[0].__doc__[base_para_index:]) + cls.__doc__ = full_doc return cls