-
Notifications
You must be signed in to change notification settings - Fork 31
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
Comment generation logic improved. #36
base: main
Are you sure you want to change the base?
Comment generation logic improved. #36
Conversation
…generated comment only while maintaining backward compatibility. Improved logic to write generated comments back to the file saving tokens which can directly affect cost for comment generation
Hey @Nisarg1112 awesome work! Will have a close look asap. But your concerns are justified, the improvements make sense to me. Very good suggestions! |
Hey, @fynnfluegge Did you get a chance to look at these changes? |
Hey @Nisarg1112 had a closer look now. Also did some manual tests. I think there is a bug in Here I started also writing some unit tests to write the comments back to the file https://github.com/fynnfluegge/doc-comments-ai/tree/chore/write_code_to_file_tests. Let me know if you need some help 🙌 |
# This function retrieves the comment pattern for a specified programming language | ||
def get_comments_pattern_for_language(language): | ||
comment_patterns = { | ||
"python": r"#.*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would prefer to use the value of the enum constants.Language
as key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool!
print(f"✅ Doc comment for {method_name} generated.") | ||
|
||
print(f"📊 Total Input Tokens: {total_original_tokens}") | ||
print(f"🚀 Total Generated Tokens: {total_generated_tokens}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these outputs! Maybe we can add a --verbose
argument and only output token details in verbose mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure nice idea! I'll make this change.
Yeah right! I tested it for Haskell only, we should definitely add unit tests. i'll work on it. |
Issues this PR focuses on:
improvements added to solve above issues:
--inline
or--comment_with_source_code
argument is provided, the tool will generate comments along with the corresponding code.--inline
comment or the--comment_with_source_code
argument is specified, the tool replaces the original code block in the file.