Carotte.Documentation 1.0.0-preview.3

This is a prerelease version of Carotte.Documentation.
dotnet add package Carotte.Documentation --version 1.0.0-preview.3
                    
NuGet\Install-Package Carotte.Documentation -Version 1.0.0-preview.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Carotte.Documentation" Version="1.0.0-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carotte.Documentation" Version="1.0.0-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="Carotte.Documentation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Carotte.Documentation --version 1.0.0-preview.3
                    
#r "nuget: Carotte.Documentation, 1.0.0-preview.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Carotte.Documentation@1.0.0-preview.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Carotte.Documentation&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Carotte.Documentation&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Tool

Carotte.Documentation ๐Ÿฅ•๐Ÿ“–

NuGet Version License: MIT .NET

Carotte.Documentation is an automated documentation generation engine for Carotte microservices. It inspects compiled assemblies and C# XML doc comments to generate comprehensive Markdown specifications, interactive Mermaid topology diagrams, and AsyncAPI v3.0 definitions (YAML / JSON) with JSON Schemas.


๐Ÿš€ Features

  • ๐Ÿ“„ AsyncAPI v3.0 Specification Export: Full AsyncAPI 3.0 export (YAML / JSON) complete with AMQP channel bindings (exchanges, queues, routing keys, dead letters).
  • ๐Ÿ“Š Interactive Mermaid Diagrams: Visual representation (graph LR) of message publishers, exchanges, queues, consumers, and Dead-Letter Exchanges/Queues (DLX/DLQ).
  • ๐Ÿ“‹ Data Contracts & JSON Schema: Automatic extraction of payload schemas, property types, and XML comments (/// <summary>).
  • ๐Ÿ›ก๏ธ Specification Validation: Built-in AsyncApiDocumentValidator to ensure generated AsyncAPI documents strictly conform to the AsyncAPI 3.0 standard.
  • ๐Ÿงช Architecture & Unit Testing: Execute documentation generation as part of your test suite (xUnit, NUnit) to enforce documentation up-to-date validation and prevent documentation drift (doc drift) in CI/CD pipelines.

๐Ÿ“ฆ Installation

Install the package via NuGet:

dotnet add package Carotte.Documentation

๐Ÿ’ป Programmatic Usage

1. Generate Markdown Documentation

using Carotte.Documentation;

var generator = new CarotteDocGenerator();

// Generate Markdown string
string markdown = generator.Generate(typeof(Program).Assembly);

// Or generate directly to a file
await generator.GenerateToFileAsync(
    typeof(Program).Assembly, 
    outputPath: "docs/MESSAGING.md",
    options: new CarotteDocumentationOptions
    {
        Title = "Order Service Messaging Architecture",
        IncludeDiagram = true,
        IncludeDataContracts = true
    });

2. Generate AsyncAPI v3.0 (YAML / JSON)

using Carotte.Documentation.AsyncApi;

var asyncApiGenerator = new AsyncApiGenerator();

var options = new CarotteAsyncApiOptions
{
    Title = "Order Microservice Messaging API",
    Version = "1.0.0",
    Validate = true // Validates AsyncAPI schema automatically
};

// Generate YAML
string yaml = await asyncApiGenerator.GenerateYamlAsync(typeof(Program).Assembly, options);
await File.WriteAllTextAsync("docs/asyncapi.yaml", yaml);

// Generate JSON
string json = await asyncApiGenerator.GenerateJsonAsync(typeof(Program).Assembly, options);
await File.WriteAllTextAsync("docs/asyncapi.json", json);

3. Generate Standalone Mermaid Diagram

using Carotte.Documentation;

var diagramGenerator = new MermaidDiagramGenerator();
string mermaidGraph = diagramGenerator.GenerateDiagram(typeof(Program).Assembly);

๐Ÿงช Architecture Testing Example (CI Guard against Doc Drift)

Use Carotte.Documentation in an automated test to ensure documentation stays in sync with code changes:

[Fact]
public async Task MessagingDocumentation_ShouldBeUpToDate()
{
    var generator = new CarotteDocGenerator();
    var currentDoc = generator.Generate(typeof(Program).Assembly);

    var existingDocPath = Path.Combine(AppContext.BaseDirectory, "../../../docs/MESSAGING.md");
    var existingDoc = await File.ReadAllTextAsync(existingDocPath);

    Assert.Equal(existingDoc.Trim(), currentDoc.Trim());
}

โš™๏ธ Configuration Options

CarotteDocumentationOptions

Property Type Default Description
Title string? Assembly name Document main heading
IncludeDiagram bool true Include Mermaid topology graph
IncludeDataContracts bool true Include detailed message property schemas
XmlDocPath string? null Path to compiler-generated XML doc comments
Namespaces IReadOnlyList<string> [] Filter scanned types by namespaces

๐Ÿ“„ License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.3 64 8/31/2026
1.0.0-preview.2 61 8/30/2026