I need to modify docstrings in a bunch of files, to add the default values of input parameters to them, if present in the class constructor or the function signature.
So let say, I have the following given:
# a bunch of code
class A:
"""A good class.
Parameters
----------
p : int
A powerful parameter.
q : float, optional
An even more powerful parameter.
"""
def __init__(self, p=3, q=.3):
self.p = p
self.q = q
# a bunch of more code
I need to go through the whole file, find all such instances, and change them to:
# a bunch of code
class A:
"""A good class.
Parameters
----------
p : int, optional (default=3)
A powerful parameter.
q : float, optional (default=.3)
An even more powerful parameter.
"""
def __init__(self, p=3, q=.3):
self.p = p
self.q = q
# a bunch of more code
And then save it back to the same or a different file.
I'm trying to make sure the default values are mentioned in docstrings, which is pretty easy for a human to do, but I'm hoping I don't have to go through the whole package manually.