Skip to main content

Docgenie: Documentation Generation Tool

Docgenie is a powerful command-line tool that leverages advanced AI models to automatically generate comprehensive documentation for your projects. It supports various documentation types, including general documentation, README files, API documentation, and code model explanations.

Table of Contents

Installation

Docgenie requires Python 3.8.1 or higher. To install it, run the following command:

pip install docgenie

Setup

  1. Initialize Configuration: Run docgenie init to create a docgenie.config.json file in your project root directory. This file contains the configuration settings for Docgenie.

  2. Configure the AI Agent:

    • Custom API: Select custom-api as the AI agent if you want to use your own API endpoint for documentation generation. You will need to provide the API URL, headers, and query parameters.
    • Gemini: Select gemini-* as the AI agent to leverage Google's Gemini model. You will need to set the DOCGENIE_MODEL_API_KEY environment variable to your Gemini API key.
  3. Define Documentation Rules:

    • Type: Select the type of documentation you want to generate for each rule (e.g., general, readme, api, model).
    • Directory: Specify the directory where the code files reside.
    • Include Patterns: Define patterns for files to be included in the documentation generation process (wildcards * and ? are supported).
    • Exclude Patterns: Define patterns for files to be excluded from the documentation generation process (wildcards * and ? are supported).
    • Output Directory: Specify the directory where the generated documentation files will be saved.
    • Search Depth: Set the depth of the directory search for code files.
    • Output Format: Choose the output format for the documentation (e.g., markdown, html, text).
    • Prompt: Add any additional instructions or context for the AI agent.

Example docgenie.config.json:

{
  "root_dir": ".", // Root directory of your project
  "agent": {
    "name": "custom-api", // Name of the AI model to use
    "config": {
      "url": "", // API URL for custom API model (if applicable)
      "headers": {}, // Headers for custom API model (if applicable)
      "query": {} // Query parameters for custom API model (if applicable)
    }
  },
  "rules": [
    {
      "type": "general", // Type of documentation to generate (general, api, readme, model)
      "dir": ".", // Directory to generate documentation for
      "include": [], // Patterns to include (using wildcard characters * and ?)
      "exclude": [], // Patterns to exclude (using wildcard characters * and ?)
      "output": ".", // Output directory
      "depth": 3, // Search depth for code analysis
      "format": "markdown", // Output format (markdown, html, text)
      "prompt": "" // Additional prompt for the AI model
    }
  ]
}

Usage

To generate documentation, run the following command:

docgenie build

Docgenie will process your code files based on the defined rules and generate documentation in the specified output directory.

Usage examples

Example 1: Generate general documentation for a Python project:

{
  "root_dir": ".",
  "agent": {
    "name": "gemini-1.5-flash",
    "config": {}
  },
  "rules": [
    {
      "type": "general",
      "dir": ".",
      "include": ["*.py"],
      "exclude": ["test_*"],
      "output": "docs",
      "depth": 3,
      "format": "markdown"
    }
  ]
}

Example 2: Generating API documentation for a RESTful API:

{
  "root_dir": "./my_api",
  "agent": {
    "name": "gemini-1.5-pro"
  },
  "rules": [
    {
      "type": "api",
      "dir": "./my_api/routes",
      "include": ["*.js"],
      "output": "./docs/api"
    }
  ]
}

Code Structure for contributors

The code is structured as follows:

  • docgenie/cli/init.py: Defines the command-line interface (CLI) for Docgenie, including the build and init commands.
  • docgenie/models/init.py: Defines the supported AI models.
  • docgenie/models/gemini.py: Implements the Gemini model for documentation generation.
  • docgenie/models/custom_api.py: Implements the Custom API model for documentation generation.
  • docgenie/main.py: Contains the core logic for loading configuration, generating prompts, and generating documentation.
  • docgenie/prompts.py: Defines the prompts used to interact with the AI models.
  • docgenie/utils/file.py: Provides utility functions for reading and writing files.
  • docgenie/utils/patterns.py: Provides functionality for matching files based on patterns.
  • docgenie/utils/languages.py: Provides functions to extract import paths from code based on the language.
  • docgenie/model.py: Handles the loading and interaction with AI models.
  • docgenie/utils/terminal.py: Provides functions for displaying colored text in the terminal.

Configuration Parameters

docgenie.config.json:

  • root_dir: Specifies the root directory of the project. Defaults to the current directory.

  • agent:

    • name: The name of the AI agent to use. Supported values: gemini-1.5-flash, custom-api.

    • config:

      • For custom-api:

        • url: The URL of the custom API endpoint.
        • headers: A dictionary of headers to be sent with the API request.
        • query: A dictionary of query parameters to be sent with the API request.

        Note: You can use {DOCGENIE_MODEL_API_KEY} and {DOCGENIE_MODEL_PROMPT} placeholders in the URL, headers, and query parameters, which will be replaced with the actual API key and prompt during runtime.

  • rules: An array of objects representing the documentation rules. Each rule object has the following properties:

    • type: The type of documentation to generate. Supported values: general, readme, api, model.
    • dir: The directory where the code files reside.
    • include: An array of patterns for files to be included in the documentation generation process.
    • exclude: An array of patterns for files to be excluded from the documentation generation process.
    • output: The directory where the generated documentation files will be saved.
    • depth: The depth of the directory search for code files.
    • format: The output format for the documentation. Supported values: markdown, html, text.
    • prompt: Additional instructions or context for the AI agent.

Environment Variables

  • DOCGENIE_MODEL_API_KEY: The API key for the Gemini model.

Contributing

Contributions are welcome! Please follow the standard contribution guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes and write unit tests.
  4. Submit a pull request.

License

Docgenie is licensed under the MIT License.

The documentation is generated using AI by docgenie. If you found any issues, please report them to the team.

Metadata

Release files for docgenie 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docgenie 0.0.3
File Size Uploaded Provenance Actions
docgenie-0.0.3.tar.gz 11.0 kB Without provenance Details for docgenie-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for docgenie 0.0.3
File Interpreter ABI Platform Actions
docgenie-0.0.3-py3-none-any.whl Python 3 none any Details for docgenie-0.0.3-py3-none-any.whl

Total release size: 25.0 kB

Release files / docgenie-0.0.3.tar.gz

Download URL docgenie-0.0.3.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9e7e0f39b0f56953f1f753d030817dd8d2efd0758e6c9684e40c78565c4e774a
BLAKE2b-256 checksum
How to use checksums
cacfb90c1c37ed63c67cb2c9038931d4fd17cedb80b718604d190350d485846d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.0 Windows/10

Release files / docgenie-0.0.3-py3-none-any.whl

Download URL docgenie-0.0.3-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0b7bce9eb7e6858e354c307e5c63289653e7f8473bc28100ab9a020d766f391
BLAKE2b-256 checksum
How to use checksums
5c4e464a11fd86251043b673b7287e4dc0a87f22f1c1d3e1b46351d1c6eced71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.0 Windows/10

Security for docgenie 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page