add configurable docstring style

This commit is contained in:
Hussam.lawen
2023-09-28 20:58:37 +03:00
parent bb12c75431
commit cd3527f7d4
2 changed files with 8 additions and 7 deletions

View File

@ -49,6 +49,7 @@ final_clip_factor = 0.9
[pr_add_docs_prompt] # /add_docs #
extra_instructions = ""
docs_style = "Google Style" # "Google Style", "Numpy Style", "Sphinx Style", "PEP257", "reStructuredText"
[pr_update_changelog] # /update_changelog #
push_changelog_changes=false

View File

@ -39,7 +39,7 @@ class PRAddDocs:
"diff": "", # empty diff for initial calculation
"extra_instructions": get_settings().pr_add_docs_prompt.extra_instructions,
"commit_messages_str": self.git_provider.get_commit_messages(),
'docs_for_language': get_docs_for_language(self.main_language),
'docs_for_language': get_docs_for_language(self.main_language, get_settings().pr_add_docs_prompt.docs_style),
}
self.token_handler = TokenHandler(self.git_provider.pr,
self.vars,
@ -183,15 +183,15 @@ class PRAddDocs:
return data
def get_docs_for_language(language):
def get_docs_for_language(language, style):
language = language.lower()
if language == 'java':
return "javadocs"
return "Javadocs"
elif language in ['python', 'lisp', 'clojure']:
return "docstrings"
return f"Docstring ({style})"
elif language in ['javascript', 'typescript']:
return "jsdocs"
return "JSdocs"
elif language == 'c++':
return "doxygen"
return "Doxygen"
else:
return "docs"
return "Docs"