autoDocstring
autoDocstring copied to clipboard
Class Docstring
Feature Request:
Is it possible to make the docstring show something different for a Class? For example, I use numpy docstring system and they have a slightly different format for class docstrings, the addition of an attributes section being the most notable.
For numpy, only public attributes should be listed, so maybe it could go through all the attributes and parse for ones without a leading _?
It's in the works :)
The docstring as inserted for the class is inconsistent at least. If the class has superclass:
class Pipeline(PackageAwareObjectMixin):
"""[summary]
:param PackageAwareObjectMixin: [description]
:type PackageAwareObjectMixin: [type]
"""
If not it's fine but:
class Something:
"""[summary]
:raises ValueError: [description]
"""
def __init__(self, a, b=None):
raise ValueError('OMG!')
I have a fork where I had this feature working for the previous version. I was still trying to debug some unreliable function detection when indented. It involved a modest re-write of the code parsing machinery. Is there any progress on similar features for the updated version, or should I update my fork and re-implement it against the new parsing and rendering machinery?
I really like this idea. @NilsJPWerner is this still in development? Thanks for writing a great extension!
Interested in this as well!
Any update on this?
Hello, Nils. I actually added class docstrings and module docstrings. It seems to be working, but I haven't been able to get the original tests running. I had never used TypeScript before (or created an extension for that matter), so I'd like to get things tested. Should I just go ahead and create a PR?
Has this been addressed? Having trouble generating docstring for classes unless it's within the constructor. Thanks
Is this still being developed or the idea died ?
I see this format to be nice for classes
class Person:
"""
A class to represent a person.
...
Attributes
----------
name : str
first name of the person
surname : str
family name of the person
age : int
age of the person
Methods
-------
info(additional=""):
Prints the person's name and age.
"""
def __init__(self, name, surname, age):
"""
Constructs all the necessary attributes for the person object.
Parameters
----------
name : str
first name of the person
surname : str
family name of the person
age : int
age of the person
"""
self.name = name
self.surname = surname
self.age = age
def info(self, additional=""):
"""
Prints the person's name and age.
If the argument 'additional' is passed, then it is appended after the main info.
Parameters
----------
additional : str, optional
More info to be displayed (default is None)
Returns
-------
None
"""
print(f'My name is {self.name} {self.surname}. I am {self.age} years old.' + additional)
I second this. I'm specifically looking for the feature for classes so that the docstring includes attributes as defined in init. What is the status of this?
I submitted a PR a while back, and Nils made some comments. I need to incorporate his suggestions and then resubmit. I have been super busy lately, but I will try to get this done within the next week or two. Thanks for inquiring guys. Hopefully it will provide the motivation to wrap this thing up.
I'm happy to go over it again @tracetidwell