Skip to content

Commit

Permalink
Better docstring for glm
Browse files Browse the repository at this point in the history
  • Loading branch information
oooo26 committed Jan 9, 2023
1 parent d1e51de commit a134343
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions python/abess/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit a134343

Please sign in to comment.