Carotte.Documentation
1.0.0-preview.3
dotnet add package Carotte.Documentation --version 1.0.0-preview.3
NuGet\Install-Package Carotte.Documentation -Version 1.0.0-preview.3
<PackageReference Include="Carotte.Documentation" Version="1.0.0-preview.3" />
<PackageVersion Include="Carotte.Documentation" Version="1.0.0-preview.3" />
<PackageReference Include="Carotte.Documentation" />
paket add Carotte.Documentation --version 1.0.0-preview.3
#r "nuget: Carotte.Documentation, 1.0.0-preview.3"
#:package Carotte.Documentation@1.0.0-preview.3
#addin nuget:?package=Carotte.Documentation&version=1.0.0-preview.3&prerelease
#tool nuget:?package=Carotte.Documentation&version=1.0.0-preview.3&prerelease
Carotte.Documentation ๐ฅ๐
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
AsyncApiDocumentValidatorto 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 | Versions 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. |
-
net10.0
- ByteBard.AsyncAPI.NET (>= 3.0.1)
- ByteBard.AsyncAPI.NET.Bindings (>= 3.0.1)
- ByteBard.AsyncAPI.NET.Readers (>= 3.0.1)
- Carotte (>= 1.0.0-preview.3)
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 |