From 02ce99c01527911220900a7bf70a203e33c87eed Mon Sep 17 00:00:00 2001 From: Farhan-Faisal Date: Wed, 15 Jan 2025 14:47:21 -0800 Subject: [PATCH] add func dto --- src/fml_doc_gen/fml_doc_gen.py | 6 ++++-- src/fml_doc_gen/func_dto.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/fml_doc_gen/func_dto.py diff --git a/src/fml_doc_gen/fml_doc_gen.py b/src/fml_doc_gen/fml_doc_gen.py index f3fc653..20dec6e 100644 --- a/src/fml_doc_gen/fml_doc_gen.py +++ b/src/fml_doc_gen/fml_doc_gen.py @@ -1,4 +1,6 @@ from typing import Callable +from fml_doc_gen import FunctionDTO + def generate_docstring_template(func: Callable, output_file: str, auto_generate: bool = False) -> str: """ @@ -39,7 +41,7 @@ def generate_docstring_template(func: Callable, output_file: str, auto_generate: pass -def read_user_function(func: Callable) -> str: +def read_user_function(func: Callable) -> FunctionDTO: """ Reads the source code of the user-provided function and extracts its signature and existing docstring (if any). @@ -65,7 +67,7 @@ def read_user_function(func: Callable) -> str: pass -def generate_template(func_signature: str) -> str: +def generate_template(func_signature: FunctionDTO) -> str: """ Generates a docstring template with placeholders for parameters, return values, and a brief description based on the provided function signature. diff --git a/src/fml_doc_gen/func_dto.py b/src/fml_doc_gen/func_dto.py new file mode 100644 index 0000000..809137c --- /dev/null +++ b/src/fml_doc_gen/func_dto.py @@ -0,0 +1,7 @@ +from typing import List, Optional, Tuple + +class FunctionDTO: + def __init__(self, name: str, output: Optional[str] = None, inputs: Optional[List[Tuple[str, str]]] = []): + self.name = name + self.output_type = output + self.inputs = [(name, input_type) for (name, input_type) in inputs]