I want to create something like API documentation website for a .NET project. As per .NET Docs the XML comments that we put on top of methods, classes etc. can be processed into an XML file by the compiler and that file can be run through tools like DocFX to generate the documentation website. .NET Docs does not provide any instructions for the latter and DocFX documentation also does not give any hint on how to use that XML file to create API documentation website.
Any ideas on how can I use that XML file with DocFX to generate API Documentation Website?
From the menu bar, choose Tools > Options to open the Options dialog box. Then, navigate to Text Editor > C# (or Visual Basic) > Advanced. In the Editor Help section, look for the Generate XML documentation comments option.
XML Documentation helps other programmers or developers to use your code (classes, functions and their members) easily by providing some useful information. XML Documentation starts with three slashes before the class or function to be documented.
Use DocFX as a command-line toolDownload and unzip docfx. zip from https://github.com/dotnet/docfx/releases, extract it to a local folder, and add it to PATH so you can run it anywhere. This command generates a default project named docfx_project . Now you can view the generated website on http://localhost:8080.
You can view XML files in different ways including using a text editor, like Notepad or TextEdit, a web browser like Safari, Chrome, or Firefox, or an XML viewer. Open your text editor or XML viewer, then open your XML to view it. Drag and drop the XML file to your web browser to view it.
If you are using .NET Core 2.2 or greater, you can update your docfx.json
to directly extract metadata from .dll
and .xml
.
DocFX "will lookup for the XML file in the same folder" with the same file name as .dll
.
Example:
{
"metadata": [
{
"src": "bin/Release/netstandard2.0/YourCompany.YourNamespace.dll",
"dest": "obj/api"
}
]
}
You should also include <GenerateDocumentationFile>true</GenerateDocumentationFile>
into your .csproj
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With