You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class_details: A list of dictionaries containing method names and their docstrings.
183
195
semaphore: synchronous primitive that implements limitation of concurrency degree to avoid overloading api.
196
+
language: Source language of the class ("python", "javascript" or "typescript").
184
197
Returns:
185
198
The generated class docstring.
186
199
"""
187
200
# Construct a structured prompt
188
-
prompt= (
189
-
f"""Generate a single Python docstring for the following class {class_details[0]}. The docstring should follow Google-style format and include:\n"""
190
-
"- Respond strictly in English.\n"
191
-
"- A short summary of what the class does.\n"
192
-
"- A list of its methods without details if class has them otherwise do not mention a list of methods.\n"
193
-
"- A list of its attributes that explicitly mentioned at the constructor method's docstring (can be adressed as attributes, properties, class fields, etc.), without types if class or constructor method has them otherwise do not mention a list of attributes.\n"
194
-
"- A brief summary of what its methods and attributes do if one has them for.\n\n"
195
-
"Return only docstring without any quotation."
196
-
)
201
+
iflanguagein ("javascript", "typescript"):
202
+
prompt= (
203
+
f"""Generate a JSDoc comment for the following JavaScript/TypeScript class {class_details[0]}. Include:\n"""
204
+
"- Respond strictly in English.\n"
205
+
"- A short summary of what the class does.\n"
206
+
"- Keep it concise; do NOT list methods/attributes as separate sections.\n"
207
+
"- Do NOT use Python conventions: no `self`, no `__init__`, no `Args:`/`Returns:`/`Attributes:` sections.\n\n"
208
+
"Return only the comment text without any quotation."
209
+
)
210
+
else:
211
+
prompt= (
212
+
f"""Generate a single Python docstring for the following class {class_details[0]}. The docstring should follow Google-style format and include:\n"""
213
+
"- Respond strictly in English.\n"
214
+
"- A short summary of what the class does.\n"
215
+
"- A list of its methods without details if class has them otherwise do not mention a list of methods.\n"
216
+
"- A list of its attributes that explicitly mentioned at the constructor method's docstring (can be adressed as attributes, properties, class fields, etc.), without types if class or constructor method has them otherwise do not mention a list of attributes.\n"
217
+
"- A brief summary of what its methods and attributes do if one has them for.\n\n"
"Update the provided JSDoc comment for the following JavaScript/TypeScript function.\n"
356
+
"Preserve correct existing information and add missing details based on the source code.\n\n"
357
+
"Guidelines:\n"
358
+
"- Improve clarity and completeness without rewriting everything from scratch.\n"
359
+
"- Use JSDoc tags: `@param {type} name` for each parameter, `@returns {type}` for the return value (omit if nothing is returned).\n"
360
+
"- Do NOT use Python conventions: no `self`, no `__init__`, no `Args:`/`Returns:` sections.\n"
361
+
"- Do NOT invent parameters or behavior.\n\n"
362
+
)
363
+
else:
364
+
guidelines= (
365
+
"Update the provided docstring for the following Python method.\n"
366
+
"Preserve correct existing information and add missing details based on the source code.\n\n"
367
+
"Guidelines:\n"
368
+
"- Improve clarity and completeness without rewriting everything from scratch.\n"
369
+
"- Be specific and clear about the method's purpose and possible usages in a system based on a field-specific main idea if it can be vague for non-participant compliances.\n"
370
+
"- If the original docstring contains only a description, add Args and Returns sections if needed.\n"
371
+
"- Describe parameters without types.\n"
372
+
"- Omit Returns section if the method does not return a value.\n"
373
+
"- Do NOT invent parameters or behavior.\n\n"
374
+
)
375
+
313
376
prompt= (
314
-
"Update the provided docstring for the following Python method.\n"
315
-
"Preserve correct existing information and add missing details based on the source code.\n\n"
316
-
"Guidelines:\n"
317
-
"- Improve clarity and completeness without rewriting everything from scratch.\n"
318
-
"- Be specific and clear about the method's purpose and possible usages in a system based on a field-specific main idea if it can be vague for non-participant compliances.\n"
319
-
"- If the original docstring contains only a description, add Args and Returns sections if needed.\n"
320
-
"- Describe parameters without types.\n"
321
-
"- Omit Returns section if the method does not return a value.\n"
0 commit comments