Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added class and module docstrings #174

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

tracetidwell
Copy link

@tracetidwell tracetidwell commented Jan 29, 2021

class docstrings are created under the class definition. They read parameters from the init() method and scan the entire class for attributes. Both parameters and attributes are listed.

module docstrings are created at the first line of the script. They scan the entire file and list out all top-level classes and methods defined therein.

All tests are passing, and I added a few unit tests and integration tests. I am not an expert at TypeScript, so this might can be improved, but I've been using this on my code for a few months now with no problems.

tracetidwell and others added 28 commits April 26, 2020 12:05
…tern allows use of getFunctionName() method; parseParameters: parseExceptions: [] inside docstringType === class
updated changelog; cleaning up code
refactoring for code climate compliance
@NilsJPWerner
Copy link
Owner

Hi this pr looks fantastic! I will review it this weekend.

@bnonni
Copy link

bnonni commented Feb 25, 2021

@NilsJPWerner any updates on your side?

@michaeloliverx
Copy link

Nice work this would be awesome!

Copy link
Owner

@NilsJPWerner NilsJPWerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay. I finally found time to check your pr. It looks very good on inspection. There are a few things that need cleaning up and adding, and I am going to try it out for a few days to check that there are no regressions.

src/docstring/templates/ncr.mustache Show resolved Hide resolved
@@ -0,0 +1,75 @@
"use strict";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? Were the existing integration tests not working?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure. I did not do that; perhaps my colleague who did a little work did. I will find out.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that was me, i'm not sure why i put it there. if the tests run without it, then remove it. i would imagine it was me being nit-picky bc my extension was telling me to add it or something

src/test/parse/get_body.spec.ts Show resolved Hide resolved
src/docstring/docstring_factory.ts Show resolved Hide resolved
package.json Show resolved Hide resolved
@@ -0,0 +1,18 @@
export function getDocstringType(functionDefinition: string, linePosition: number): string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should turn the return type into a string literal type so that we restrict to only types we define.

}

else {
return "method";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed to function since not all functions are methods.

returns: undefined,
yields: undefined,
exceptions: [],
classes: parseMethods(body, /(?:class)\s/),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be split into 2 functions instead of passing a regex into it

}
let var_ = match[1];
let type_ = guessType(match[1]);
if (!containsAttribute(attributes, var_) && !containsAttribute(args, var_) && !containsAttribute(kwargs, var_)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by this? What is going on here?

class TestClass(object):
"""[summary]

:param arg1: [description]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need an integration test for attributes.

@lieutdan13
Copy link

@tracetidwell thank you for contributing to this project. This feature would help out so many of us that have expressed interest in issue #27. It would be really helpful if you addressed the comments that the repo owner @NilsJPWerner has requested, then he can followup and get this merged and published for us all to use :)

@tracetidwell
Copy link
Author

After way, WAY too long, I am going to finish this. I resolved a number of issues, left comments on a couple others, and need to work on the rest. If this is not being maintained or doesn't seem worth it, please let me know.

@bnonni
Copy link

bnonni commented Feb 4, 2022

I haven't touched this repo in years, but I think I still have the repo cloned locally. @tracetidwell let me know if you need something from me. would love to help get this completed and merged.

@trycoast
Copy link

Any news on this?

@MaddyGuthridge
Copy link

Bumping this again? Would love to see this merged? If not, does anyone know any alternatives?

@NilsJPWerner
Copy link
Owner

If @tracetidwell or someone else wants to pick up the PR again or start fresh I would be happy to review and merge. Right now I am focused on adding the ability to update docstrings, and so work on module and class docstrings will have to come afterwards.

@silopolis
Copy link

WANT!

@NathanNull
Copy link

This would be super nice, someone finalize this and add it

@trycoast
Copy link

trycoast commented Oct 4, 2022

Yes, please make this happen 🙏

@FrankC01
Copy link

FrankC01 commented Feb 1, 2023

Really, sitting in this state for over two years? I don't think this is being maintained any longer.

@ishandandekar
Copy link

Need this please, ASAP!

@mjspeck
Copy link

mjspeck commented May 8, 2023

Any updates on this?

@yuval1337
Copy link

Did anyone perhaps forked and added this feature? I would love to use it!
It appears the repo's owner forsaken this project, as there were no pushes made in over a year.

@CmpCtrl
Copy link

CmpCtrl commented May 5, 2024

This still seems like useful functionality. Is there any chance of it being introduced? What about alternatives?

@DrJStrudwick
Copy link

@NilsJPWerner @PhilipNelson5 @tracetidwell Any movement on this? This is a really cool tool and this PR would be a great addition. If this tool as a whole is no longer being maintained then fair enough :)

@efrainMesia
Copy link

@tracetidwell @NilsJPWerner any upate on this?
is there any way of how to help here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.