XmlDocMarkdown generates Markdown from .NET XML documentation comments.
It is distributed as a class library, .NET tool, .NET Framework console app, and Cake addin.
The goal of this tool is to generate Markdown documentation for .NET class libraries that are simple enough to be read and understood in raw form, as rendered in GitHub, or when used to generate web pages using Jekyll and GitHub Pages. To that end, it generates standard GitHub Flavored Markdown without relying on raw HTML tags.
XmlDocMarkdown uses the
.xml documentation files generated when your code is compiled, so make sure they are being generated, e.g. by including
<GenerateDocumentationFile>true</GenerateDocumentationFile> in your
The most reliable way to use XmlDocMarkdown is to build and run a command-line tool that references the XmlDocMarkdown.Core class library and the assembly that you want to document. This ensures that the assembly and all of its dependencies are loaded properly.
This is easier than it sounds, because the XmlDocMarkdown.Core class library contains the full implementation of the command-line application via XmlDocMarkdownApp.Run.
<ProjectReference Include="..\RelativePathTo\MyLibrary.csproj" />
<PackageReference Include="XmlDocMarkdown.Core" Version="2.9.0" />
Build and run
XmlDocGen like you would any console app, specifying the arguments and options as documented below. For example, from the same directory as
XmlDocGen.csproj, you can generate documentation for the
MyLibrary assembly into the
> dotnet run MyLibrary docs
The command-line tool accepts the name of the input assembly, the path of the output directory, and a number of options.
The output directory will be created if necessary.
For example, the arguments
MyLibrary docs will generate Markdown documentation in the
docs directory for the
MyLibrary assembly. The compiler-generated
MyLibrary.xml file must be in the same directory as
--source <url>: The URL (absolute or relative) of the folder containing the source code of the assembly, e.g. at GitHub. Required to generate source code links in the See Also sections for types. This assumes that each type is defined in a
.cs file that matches its name.
--namespace <ns>: The root namespace of the input assembly. Used to generate source code links in the See Also sections for types. If omitted, the tool guesses the root namespace from the exported types.
--visibility (public|protected|internal|private): The minimum visibility for documented types and members. If
public, only public types and members are documented. If
protected, only public and protected types and members are documented. Similarly for
private. Defaults to
--obsolete: Generates documentation for obsolete types and members, which are not documented by default.
--external <ns>: Generates links to external documentation for the specified namespace, which must be documented in the same repository with similar options.
--clean: Delete previously generated files that are no longer used.
--verify: Executes the tool without making changes to the file system, but exits with error code 1 if changes would be made. Typically used in build scripts to ensure that any changes have been reflected in the generated code.
--dryrun: Executes the tool without making changes to the file system.
--quiet: Suppresses normal console output.
--newline (auto|lf|crlf): Indicates the newline used in the output. Defaults to
auto, which uses CRLF or LF, depending on the platform.
To implement a command-line tool, call XmlDocMarkdownApp.Run with the command-line arguments.
If you are documenting a modern .NET library and your dependencies are simple enough, you may be able to use this prebuilt .NET tool, but building your own command-line tool is recommended and documented above.
dotnet tool install xmldocmd -g
Use the path of the input assembly as the first argument. The XML documentation file should be in the same directory as the input assembly.
If you are documenting a .NET Framework library and your dependencies are simple enough, you may be able to use this prebuilt .NET Framework console app, but building your own command-line tool is recommended and documented above.
nuget install XmlDocMarkdown -excludeversion will download the latest version of
On Mac or Linux, use Mono to run
nuget as well as the command-line tool itself.
The command-line arguments and options are the same as
If your dependencies are simple enough, you may be able to use this Cake addin, but building your own command-line tool is recommended and documented above.