This feature is available exclusively as part of the Pro plan and is not included in the Lite plan. Please refer to our pricing page for more information about our plans and features.
Writing documentation for every function is time-consuming, but undocumented code creates bottlenecks during code reviews. You spend cycles explaining what functions do instead of focusing on business logic and architecture decisions. CodeRabbit generates docstrings for functions missing documentation in your PRs. Comment @coderabbitai generate docstrings or check the box in your PR walkthrough to trigger generation. The system scans your changes with ast-grep, identifies functions needing documentation, and generates docstrings that match your codebase’s existing format. Generated docstrings are committed to a new branch and opened as a PR for your review. This handles the initial documentation grunt work while keeping you in control through the standard PR review process.

How it works

1

Trigger generation

Comment @coderabbitai generate docstrings in your PR or check Generate Docstrings in the CodeRabbit Walkthrough
2

Function analysis

ast-grep scans your PR changes to identify functions missing docstrings or with incomplete documentation
3

Format-aware generation

AI analyzes your existing docstrings to detect format patterns (JSDoc, Google-style, Sphinx) and generates matching documentation
4

PR workflow

Generated docstrings are committed to a new branch with a PR opened against your original branch for review and merge (typically 30-60 seconds)
Docstrings PR example showing generated documentation in a pull request You review the generated PR like any other code change. CodeRabbit preserves existing docstrings and only documents functions that genuinely need it.
CodeRabbit automatically detects your docstring format by analyzing existing documentation patterns. It matches JSDoc, Google-style, Sphinx, custom formats, or even Go’s doc comment conventions without any configuration.

Platform and integration support

Full PR workflow

Complete integration:
  • GitHub
  • GitLab
  • Azure DevOps
Branch creation, PR opening, full review workflow

Comment integration

Streamlined process:
  • Bitbucket
Docstrings delivered as PR comments while we complete full integration

Language coverage

18+ languages supported:
  • Python, JavaScript, TypeScript
  • Go, Rust, Java, Kotlin, Swift
  • C, C++, C#, Ruby, PHP, Lua, Elixir, Bash
Support depends on ast-grep parsing capabilities
Bitbucket integration: Currently receives docstrings as PR comments rather than separate PRs. Full workflow support is in development.

Configure per-directory styles

Reviewing generated docstrings

When CodeRabbit opens a docstring PR, focus your review on: Content accuracy:
  • Parameter descriptions match actual function behavior
  • Return value documentation reflects real outputs
  • Edge cases and error conditions are correctly described
Format consistency:
  • Generated format matches your codebase conventions
  • Examples use appropriate syntax for your language
  • Terminology aligns with your project’s vocabulary
Completeness:
  • All parameters are documented with appropriate detail
  • Complex functions include usage examples
  • Error conditions and exceptions are covered
Most generated docstrings need minimal adjustment. Common tweaks include refining parameter descriptions or adding project-specific terminology.

Technical implementation

CodeRabbit uses ast-grep for precise code parsing across different programming languages and coding styles. This enables accurate function detection while respecting your code structure and automatically detecting your preferred docstring format. Language support depends on ast-grep capabilities. To request additional language support, contribute to the ast-grep language addition guide. Currently supported: Bash, C, C++, C#, Elixir, Go, Java, JavaScript, Kotlin, Lua, PHP, Python, React TypeScript, Ruby, Rust, Swift, TypeScript.

Next steps

Ready to enhance your development workflow? Explore these related features and resources: