Docstring generator prompt for any language
Turn undocumented functions into properly commented code with parameter, return, and behavior descriptions in seconds.
متى تستخدم هذا البرومبت
- Before publishing a library or internal package.
- When inheriting undocumented code.
- To prep code for a documentation generator like Sphinx or JSDoc.
نص البرومبت
Add clear {{language}} docstrings and inline comments to the code below, following the {{framework}} documentation style. Explain purpose, parameters, return values, and any non-obvious logic.
{{CLIPBOARD}}{{language}}{{framework}}{{CLIPBOARD}}الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».
كيف تستخدمه
- انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
- الصقه في ChatGPT أو Claude أو Gemini.
- عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.
مثال على النتيجة
def calculate_discount(price: float, percent: float) -> float:
\"\"\"Calculate the discounted price.
Args:
price: Original price before discount.
percent: Discount percentage (0-100).
Returns:
The price after applying the discount.
\"\"\"
return price * (1 - percent / 100)نصائح للاستخدام
- Name the docstring convention you want (Google, NumPy, JSDoc, PHPDoc).
- Ask it to flag any parameters whose purpose is unclear from the code alone.
- Re-generate after signature changes to keep docs in sync.
أسئلة شائعة
- Does it guess what unclear code does?
- It documents based on what the code visibly does; if logic is ambiguous it will note the uncertainty rather than invent behavior.
- Can it match my team's existing doc style?
- Yes, paste one existing example alongside your code and ask it to match that format.