Skip to content

Commit dcfed54

Browse files
committed
feat: change docstring generator to doxygen
1 parent 90e32d0 commit dcfed54

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ venv/
118118
ENV/
119119
env.bak/
120120
venv.bak/
121+
.python-version
121122

122123
# Spyder project settings
123124
.spyderproject

scripts/generate_apis.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def clean_docstring_text(self, text: str) -> str:
122122
# Remove newline characters and replace with spaces
123123
text = text.replace('\n', ' ').replace('\r', ' ')
124124

125+
# Remove escaped newline sequences (literal \n in the string)
126+
text = text.replace('\\n', ' ')
127+
125128
# Convert markdown links [text](url) -> text
126129
import re
127130
text = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', text)
@@ -244,12 +247,12 @@ def _build_docstring_content(self, api: Dict[str, Any], imperative_description:
244247
param_name = f"{param_name}_"
245248

246249
prop_desc = self.clean_docstring_text(prop_def.get("description", f"The {prop_name} parameter."))
247-
lines.append(f" {param_name} (type): {prop_desc}")
250+
lines.append(f" @param {param_name} {prop_desc}")
248251

249252
return "\n".join(lines)
250253

251254
def generate_docstring(self, api: Dict[str, Any]) -> str:
252-
"""Generate function docstring."""
255+
"""Generate function docstring in Doxygen format."""
253256
# Clean the description text
254257
clean_description = self.clean_docstring_text(api["description"])
255258
# Convert to imperative mood (Pydocstyle D402)
@@ -260,12 +263,11 @@ def generate_docstring(self, api: Dict[str, Any]) -> str:
260263
has_backslashes = '\\' in docstring_content
261264

262265
if has_backslashes:
263-
lines = [f' r"""{imperative_description}']
266+
lines = [f' r"""! {imperative_description}']
264267
else:
265-
lines = [f' """{imperative_description}']
268+
lines = [f' """! {imperative_description}']
266269
lines.append("")
267-
lines.append(" Args:")
268-
lines.append(" card (Notecard): The current Notecard object.")
270+
lines.append(" @param card The current Notecard object.")
269271

270272
properties = api["properties"]
271273

@@ -279,14 +281,12 @@ def generate_docstring(self, api: Dict[str, Any]) -> str:
279281
if param_name in self.reserved_keywords:
280282
param_name = f"{param_name}_"
281283

282-
prop_type = self.get_python_type_hint(prop_def)
283284
prop_desc = self.clean_docstring_text(prop_def.get("description", f"The {prop_name} parameter."))
284-
lines.append(f" {param_name} ({prop_type}): {prop_desc}")
285+
lines.append(f" @param {param_name} {prop_desc}")
285286

286287

287288
lines.append("")
288-
lines.append(" Returns:")
289-
lines.append(" dict: The result of the Notecard request.")
289+
lines.append(" @return The result of the Notecard request.")
290290
lines.append(' """')
291291

292292
return "\n".join(lines)
@@ -359,16 +359,13 @@ def group_apis_by_module(self, apis: List[Dict[str, Any]]) -> Dict[str, List[Dic
359359

360360
def generate_module_file(self, module_name: str, apis: List[Dict[str, Any]]) -> str:
361361
"""Generate complete module file content."""
362-
lines = [f'"""{module_name} Fluent API Helper."""']
362+
lines = [f'"""! @file {module_name}.py']
363+
lines.append(f"@brief {module_name} Fluent API Helper.")
363364
lines.append("")
364-
lines.append("##")
365-
lines.append(f"# @file {module_name}.py")
366-
lines.append("#")
367-
lines.append(f"# @brief {module_name} Fluent API Helper.")
368-
lines.append("#")
369-
lines.append("# @section description Description")
370-
lines.append(f"# This module contains helper methods for calling {module_name}.* Notecard API commands.")
371-
lines.append("# This module is optional and not required for use with the Notecard.")
365+
lines.append("@section description Description")
366+
lines.append(f"This module contains helper methods for calling {module_name}.* Notecard API commands.")
367+
lines.append("This module is optional and not required for use with the Notecard.")
368+
lines.append('"""')
372369
lines.append("")
373370
lines.append("from notecard.validators import validate_card_object")
374371

0 commit comments

Comments
 (0)