Unveiling the Power of /add_docs Command: Automated Documentation Suggestions

Documentation is the backbone of a robust codebase, enhancing code understanding and collaboration. The "/add_docs" command within CodiumAI's PR-Agent suite automates the documentation process, providing insightful suggestions for code components altered in a Pull Request (PR). Let's dive into how this command can transform your development workflow.

Understanding /add_docs Command

The "/add_docs" tool scans PR code changes and generates documentation suggestions for modified code components, such as functions and classes. Whether you're contributing to Python, Java, C++, JavaScript, or TypeScript projects, this command streamlines the documentation process.

How to Trigger Documentation Suggestions

Invoke the "/add_docs" command manually by commenting on any PR:


The tool swiftly responds with a detailed list of modified files, accompanied by docstrings for each altered code component.

add_docs add_docs add_docs

Understanding the Output of /add_docs Command

When you invoke the /add_docs command on a pull request (PR), the tool provides a detailed summary of the modified files and their associated code components. Here's a breakdown of the output:

PR Documentation Overview

  • List of Modified Files: A comprehensive list of files altered in the PR is presented. Each file serves as a clickable link, allowing you to explore changes at the file level.
  • File-Level Details: For each file, specific details are provided. For instance, in the example output, the file "pr_code_suggestions.py" is selected for detailed documentation.

File-Level Details

  • Component-Level Information: The tool categorizes code components within the selected file. Components include classes, functions, or methods that have undergone changes in the PR.
  • Git Difference: For each code component, the Git difference is displayed, indicating the number of insertions and deletions. This provides a quick overview of the modifications made to the code.

Component-Level Details

Explaning rank_suggestions (method) [+2/-5]:

Additional details are presented within each code component. In this example, the "rank_suggestions" method is explored. The output includes:

  • Component Signature: The method signature, indicating its structure and parameters.
  • Docstring: The documentation string associated with the method, providing a clear explanation of its purpose and functionality.
  • Git Difference: The specific changes made to the method, denoted by the number of insertions (+2) and deletions (-5).

Exploring Further

  • Navigation: The output is designed to facilitate seamless navigation. Clicking on a file directs you to the code components within that file. Similarly, clicking on a specific function or method reveals detailed information about its signature, parameters, return type, and associated docstring.

By presenting a hierarchical view of PR changes, from modified files down to individual code components, the /add_docs command empowers reviewers and contributors to delve into specific details, fostering a more informed and efficient code review process.

Configuration Options:

1. docs_style:

Description: The docs_style option allows you to specify the exact style of the documentation (for Python docstrings).


  • google
  • numpy
  • sphinx
  • restructuredtext
  • plain

Default Value: sphinx

Example: [pr_add_docs] docs_style = "google"

Explanation: This option defines the preferred style for the generated documentation, and you can choose from popular styles like Google, NumPy, Sphinx, reStructuredText, or plain.

2. extra_instructions:

Description: The extra_instructions option allows you to provide additional instructions to the tool, guiding it to specific areas of focus.

Values: String (multi-line supported)

Default Value: Empty

Example: [pr_add_docs] extra_instructions = """ Focus on the changes in the file X. Ignore changes in Y. """

Use-Cases: Elevating Documentation Practices

  • New Component Documentation: Leverage the tool for languages that aren't fully supported, ensuring documentation suggestions for new components in the PR.
  • Efficient Review Process: Streamline code reviews by providing clear and consistent documentation, enhancing collaboration among contributors.
  • Consistent Documentation Styles: Enforce a standardized documentation style across your projects, ensuring clarity and uniformity in code understanding.
  • Time-Saving Automation: Automate the time-consuming task of manual documentation, allowing developers to focus on coding while maintaining a well-documented codebase.

Frequently Asked Questions

  • What programming languages does the /add_docs command support?

    The /add_docs tool currently fully supports Python, Java, C++, JavaScript, and TypeScript. For languages not fully supported, the tool suggests documentation exclusively for new components introduced in the PR.

  • Can I customize the documentation style generated by the /add_docs command?

    Yes, you can customize the documentation style using the "docs_style" configuration option. Choose from styles such as google, numpy, sphinx, restructuredtext, or plain to align with your project's preferences.

  • Can I provide specific instructions to the tool for more tailored documentation suggestions?

    Absolutely! Utilize the "extra_instructions" configuration option to provide specific instructions to the tool. Whether you want to focus on changes in a particular file or ignore specific modifications, these instructions ensure a more tailored output.

Have More Questions?