Welcome to DocToolkit

DocToolkit is a .NET library that extracts metadata from .NET assemblies and transforms XML documentation comments into structured documentation models. Unlike traditional documentation generators that produce fixed output, DocToolkit provides the building blocks for creating custom documentation systems tailored to your specific needs.

Why Choose DocToolkit

Complete Control Over Output: DocToolkit gives you complete control over the final documentation format by separating the rendering logic from the underlying data processing, allowing you to generate documentation in any format—HTML, Markdown, or completely custom formats.

Comprehensive Assembly Analysis: DocToolkit uses reflection-only assemblies via MetadataLoadContext to extract namespaces, types, members, and their relationships. It captures inheritance hierarchies, generic type parameters, member signatures, and all the metadata you need for rich documentation.

Advanced XML Documentation Processing: DocToolkit parses and transforms XML documentation files using configurable XSLT stylesheets, supporting standard XML documentation tags plus extended Sandcastle tags for comprehensive coverage. It automatically resolves cross-references between documentation elements.

Built for Integration: DocToolkit is designed to integrate seamlessly with existing documentation workflows. It includes customizable URL management with built-in configurations for popular platforms like Azure DevOps Wiki, Microsoft Docs, and DocFx, plus support for custom URL schemes.

Beyond API Documentation: DocToolkit supports both API reference documentation and conceptual topics, allowing you to create comprehensive documentation systems that include tutorials, guides, and standalone content alongside your code documentation.

How DocToolkit Works

The documentation generation process follows three carefully designed phases:

Metadata Extraction

DocToolkit loads .NET assemblies using the System.Reflection.MetadataLoadContext package for reflection-only metadata extraction. It employs an abstract layer of interfaces to access and organize assembly metadata, including types, members, and their relationships.

This metadata is then organized into collections that represent namespaces, type hierarchies, and member groupings—providing you with a complete picture of your codebase structure for documentation generation.

XML Processing

XML documentation files are parsed and transformed into structured documentation models. XSLT stylesheets convert XML tags into your target output formats while preserving cross-references and semantic relationships.

Custom Output Generation

Documentation models are passed to your custom renderers that generate the final output. DocToolkit provides the infrastructure for customizable URL generation, cross-reference resolution, format-specific encoding, and specialized TextWriter wrappers for HTML and Markdown content with built-in minification support—you focus on the presentation layer.

XML Documentation Processing

DocToolkit processes XML documentation files generated by .NET compiler with comprehensive support for standard and extended documentation tags. The library handles cross-reference resolution, validation, and transformation to your target output formats. For a complete list of supported tags, see the XML Documentation Tags Reference.

Built-in Transformations

Two production-ready XSLT stylesheets handle common scenarios:

Custom Transformations

Need something specific? Implement custom XSLT stylesheets or bypass XSLT entirely by implementing the XML transformer interface for complete control over the transformation process.

Getting Started

Install Kampute.DocToolkit via NuGet:

dotnet add package Kampute.DocToolkit

Implementation Steps

DocToolkit separates concerns cleanly—it handles the complex metadata extraction and XML processing while you implement the documentation rendering logic that fits your needs.

Step 1: Create Your Documentation Renderer

Extend the DocumentPageRenderer class to define how documentation models are converted to your desired output:

public class MyDocumentRenderer : DocumentPageRenderer
{
    protected override void Render(TextWriter writer, PageCategory category, IModel model)
    {
        // Convert the documentation model to your desired output format
        // The model contains all extracted metadata and processed XML comments
    }
}

Step 2: Configure the Documentation Context

Set up your assemblies, XML documentation sources, and processing options:

// Create context for generating Markdown pages with Azure DevOps Wiki links
using var context = DocumentationContextBuilder
    .DevOpsWiki()
    .AddAssembly("path/to/MyLibrary.dll")
    .AddXmlDoc("path/to/MyLibrary.xml")
    .Build();

Step 3: Generate Documentation

Process your assemblies and generate output files:

var renderer = new MyDocumentRenderer();
var composer = new FileSystemDocumentationComposer(renderer);

// Generate documentation files in the specified directory
composer.GenerateDocumentation(context, "/output/directory");

The composer calls your renderer for each documentation page, passing the processed model data that your renderer converts to the final output format.

Support and Community

DocToolkit is an open-source project released under the MIT License. Contributions, bug reports, and feature requests are welcome.