P
💻DeveloppementBeginnerAll AIs

Document Code with JSDoc/TSDoc

Generate professional and complete JSDoc/TSDoc documentation for your functions and classes with concrete examples.

Paste in your AI

Adapt this prompt

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

You are an expert in software technical documentation. I need to document my [JavaScript/TypeScript] code in a professional and complete way so that my colleagues can use it easily.

Code to document:

[paste the code]

Context:

  • Audience: [e.g. internal developers, open-source contributors, library users]
  • Documentation style: [e.g. standard JSDoc, TSDoc for TypeScript, specific format]
  • Generation tool: [e.g. TypeDoc, JSDoc, Storybook]
  • Level of detail required: [e.g. minimal for internal use, complete for public API]

Generate the complete documentation with:

  1. General description: a one-sentence summary followed by a detailed paragraph explaining the role, the context of use, and important limitations.
  2. Parameters: document each parameter with its type, whether it is required/optional, its default value, and a clear description.
  3. Return value: exact type and description of what is returned, including special cases (null, undefined, rejected Promise).
  4. Exceptions: list the errors that can be thrown along with the conditions that trigger them.
  5. Code examples: provide 2-3 concrete examples covering basic usage and more complex cases.
  6. Special annotations: @deprecated, @since, @see, @internal as needed.

Make sure the documentation is precise enough that a developer can use the function without reading its implementation.

Personalize this prompt with Léa · AI assistant

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

This prompt is centered on the final goal of documentation: enabling a developer to use a function without reading its implementation. This constraint forces the AI to produce exhaustive documentation rather than a simple code paraphrase. Requesting 2-3 concrete examples is the most valuable element of this prompt: documentation with examples has a much higher adoption rate than textual documentation alone. Examples drastically reduce the learning curve for new API users. Adapting to context (internal use vs public API) is important as it calibrates the appropriate level of detail: over-documenting simple internal code is a waste of time, while under-documenting a public API creates support debt.

Use Cases

API and library documentationImproving code maintainabilityTechnical documentation generation

Expected Output

Complete JSDoc/TSDoc comments with descriptions, types, documented parameters, return values, and code examples.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateClaude

Task brief for Claude Code: frame a feature end to end

Brief template to delegate a complete feature to Claude Code: goal, starting point, constraints, definition of done, working rules and recap format.

1681
💻DeveloppementIntermediateClaude

Write a project's CLAUDE.md: the brief Claude Code reads at every session

Turns your project description into a dense CLAUDE.md: commands, structure, conventions, pitfalls, off-limits areas and situations where the agent must ask before acting.

640
💻DeveloppementAdvancedAll AIs

Design a Secure Webhook API

Design a webhook API with event subscriptions, signed deliveries, retry limits, and a delivery log your support team can inspect.

411
💻DeveloppementIntermediateAll AIs

Generate Storybook Stories for UI Components

Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.

474