Skip to content

Commit

Permalink
Add label to identify devtale generated docstrings (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
betogaona7 authored Sep 15, 2023
1 parent a1cb4b3 commit f9c1751
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PHPAggregator,
PythonAggregator,
)
from devtale.constants import ALLOWED_EXTENSIONS, LANGUAGES
from devtale.constants import ALLOWED_EXTENSIONS, DOCSTRING_LABEL, LANGUAGES
from devtale.utils import (
build_project_tree,
extract_code_elements,
Expand Down Expand Up @@ -350,7 +350,9 @@ def process_file(

logger.info("add dev tale summary")
summaries = split_text(str(code_elements_dict["summary"]), chunk_size=9000)
tale["file_docstring"] = redact_tale_information("top-level", summaries)["text"]
tale["file_docstring"] = (
DOCSTRING_LABEL + "\n" + redact_tale_information("top-level", summaries)["text"]
)

logger.info(f"save dev tale in: {save_path}")
with open(save_path, "w") as json_file:
Expand Down
2 changes: 2 additions & 0 deletions devtale/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
".go": Language.GO,
".js": Language.JS,
}

DOCSTRING_LABEL = "@DEVTALE-GENERATED:"
7 changes: 7 additions & 0 deletions devtale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from langchain.output_parsers import PydanticOutputParser
from langchain.text_splitter import RecursiveCharacterTextSplitter

from devtale.constants import DOCSTRING_LABEL
from devtale.schema import FileDocumentation
from devtale.templates import (
CODE_EXTRACTOR_TEMPLATE,
Expand Down Expand Up @@ -186,6 +187,9 @@ def fuse_tales(tales_list, code, code_elements_dict):
class_name, code, code_elements_dict["classes"]
):
unique_classes.add(class_name)
class_info["class_docstring"] = (
DOCSTRING_LABEL + "\n" + class_info["class_docstring"]
)
fused_tale["classes"].append(class_info)
else:
if tale not in errors:
Expand All @@ -199,6 +203,9 @@ def fuse_tales(tales_list, code, code_elements_dict):
method_name, code, code_elements_dict["methods"]
):
unique_methods.add(method_name)
method_info["method_docstring"] = (
DOCSTRING_LABEL + "\n" + method_info["method_docstring"]
)
fused_tale["methods"].append(method_info)
else:
if tale not in errors:
Expand Down

0 comments on commit f9c1751

Please sign in to comment.