-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
102 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Callable | ||
from fml_doc_gen import FunctionDTO | ||
|
||
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. | ||
Parameters | ||
---------- | ||
func_signature : str | ||
The signature of the user-defined function. | ||
Returns | ||
------- | ||
str | ||
The docstring template with placeholders. | ||
Examples | ||
-------- | ||
>>> func_signature = "example_func(a, b)" | ||
>>> template = generate_template(func_signature) | ||
>>> print(template) | ||
\"\"\"Parameters | ||
---------- | ||
a : type | ||
b : type | ||
Returns | ||
------- | ||
return_type | ||
\"\"\" | ||
""" | ||
|
||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import Callable | ||
from fml_doc_gen import FunctionDTO | ||
|
||
|
||
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). | ||
Parameters | ||
---------- | ||
func : Callable | ||
The user-defined function. | ||
Returns | ||
------- | ||
str | ||
The function signature as a string. | ||
Examples | ||
-------- | ||
>>> def example_func(a, b): | ||
... return a + b | ||
... | ||
>>> read_user_function(example_func) | ||
'example_func(a, b)' | ||
""" | ||
|
||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
def write_docstring_to_file(docstring: str, output_file: str) -> None: | ||
""" | ||
Writes the generated docstring to a specified output file. | ||
Parameters | ||
---------- | ||
docstring : str | ||
The docstring to be written to the file. | ||
output_file : str | ||
The path to the output file. | ||
Returns | ||
------- | ||
None | ||
This function does not return anything. | ||
Examples | ||
-------- | ||
>>> docstring = \"\"\"Parameters | ||
---------- | ||
a : int | ||
b : int | ||
Returns | ||
------- | ||
int | ||
\"\"\" | ||
>>> output_file = 'docstring_output.txt' | ||
>>> write_docstring_to_file(docstring, output_file) | ||
# This writes the docstring to 'docstring_output.txt' | ||
""" | ||
|
||
pass |