diff --git a/devtale/aggregators/php.py b/devtale/aggregators/php.py index 6755595..8e9b87b 100644 --- a/devtale/aggregators/php.py +++ b/devtale/aggregators/php.py @@ -7,10 +7,19 @@ def __init__(self): def document(self, documentation, code): documented_code = code + documented_code = self._document_file(documentation, documented_code) documented_code = self._document_functions(documentation, documented_code) documented_code = self._document_classes(documentation, documented_code) return documented_code + def _document_file(self, documentation, code): + file_description = documentation["file_docstring"] + docstring = self._format_docstring(file_description, 0) + + code = docstring + "\n" + code + + return code + def _document_functions(self, documentation, code): for method_data in documentation["methods"]: method_name = method_data["method_name"] diff --git a/devtale/aggregators/python.py b/devtale/aggregators/python.py index 4f7fa2e..0425d3a 100644 --- a/devtale/aggregators/python.py +++ b/devtale/aggregators/python.py @@ -21,6 +21,7 @@ def __init__(self): pass def document(self, documentation, code): + code = self._add_file_level_docstring(code, documentation) code_w_placeholders = self._add_placeholders(code) code_definitions = self._get_code_definitions(code_w_placeholders) documented_code = code @@ -55,6 +56,14 @@ def document(self, documentation, code): return documented_code + def _add_file_level_docstring(self, code: str, documentation): + file_description = documentation["file_docstring"] + docstring = f'"""{file_description}\n"""\n' + + code = docstring + "\n" + code + + return code + def _add_placeholders(self, code: str): code_tree = ast.parse(code) placeholder_adder = Placeholder()