Overview#

This is an extension which uses AI powered Langchain agents to write documentation for python kit extensions automatically.

There are 4 key deliverables in the extension:

  • Update python file with docstring for classes, methods and modules

  • A carb setting list provided or used by the extension

  • An overview of the extension with the high level functionality summarized and the list of key APIs (classes/methods)

  • A usage page which shows a few example code snippets of how to use the extension.

Implementation details#

Here’s an overview of the structure and key components of the doc_agents module:

graph LR A[doc_agents] --> B[agents] A --> C[modifiers] B --> D[docstring_agent] B --> E[overview_agent] B --> F[usage_agent] B --> G[settings_agent] B --> H[cpp_overview_agent] B --> I[command_agent] B --> J[diagram_agent] C --> K[docstring_injecter] C --> L[code_validator_modifier] C --> M[overview_updater_modifier] C --> N[settings_validator_modifier] C --> O[code_reviewer_modifier]

The doc_agents module consists of two main submodules: agents and modifiers.

  1. agents submodule:

    • Contains various agent classes responsible for generating and managing documentation.

    • Key components:

      • docstring_agent: Provides agents for generating docstrings for classes, class methods, functions and modules;

      • overview_agent: Generates an overview documentation for an extension.

      • usage_agent: Generates usage documentation with code examples.

      • settings_agent: Lists out carb settings defined and used in the extension

      • cpp_overview_agent: Generates overview documentation specifically for C++ extensions.

      • command_agent: Generates usage documentation and code examples for command APIs.

      • diagram_agent: Creates Mermaid diagrams that visualize relationships between classes in Python modules.

  2. modifiers submodule:

    • Contains modifier classes that can be applied to the documentation generation process.

    • Key components:

      • docstring_injecter: Injects generated docstrings into the source code.

      • code_validator_modifier: Validates generated code snippets and try to fix runtime errors.

      • overview_updater_modifier: Injects the important API documentation links.

      • settings_validator_modifier: Validates the generated settings.

      • code_reviewer_modifier: Reviews usage documentation for code quality, duplication, and API usage validation.

The agents submodule defines the core functionality for generating different types of documentation, while the modifiers submodule provides additional modifications and post-processing capabilities to enhance the generated documentation.