share
Stack OverflowC# documentation generator?
[+190] [15] ryeguy
[2009-03-13 03:24:14]
[ c# visual-studio documentation-generation ]
[ http://stackoverflow.com/questions/641364/c-documentation-generator ] [DELETED]

Is there any kind of documentation generator for C#? Like something that would put the xml-ish documentation right above the method/class declarations? Is there a tool or is it tucked away somewhere in VS 2008?

(1) For comparison, the de-facto standard for documenting Python projects is Sphinx, which produces beautiful docs. Example: scikit-learn.org/stable/modules/tree.html#classification - Colonel Panic
Try docfx - vicancy
[+206] [2013-01-19 23:48:16] Daniel

A comprehensive list:

Free and/or Open Source Options

  • Sandcastle [1]. Perhaps one of the most popular choices. Sandcastle produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. Sandcastle has the following key features: works with or without authored comments, supports Generics and .NET. (Note: Sandcastle has switched hands to SHFB. For the old Sandcastle project, go here [2].)

  • GhostDoc [3]. Likely second in popularity to Sandcastle. GhostDoc is a free add-in for Visual Studio that automatically generates XML documentation comments for C#. Either by using existing documentation inherited from base classes or implemented interfaces, or by deducing comments from name and type of e.g. methods, properties or parameters. Basically it generates the /// comments above the methods, class, etc for you.

  • Doxygen [4]. Works across many programming languages. It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual (in LATEX) from a set of documented source files. (This generator is my personal choice.)

  • Docu [5]. A documentation generator for .Net that isn't complicated, awkward, or difficult to use. Given an assembly and the XML that's generated by Visual Studio, Docu can produce an entire website of documentation with a single command.

  • Nocco [6]. Nocco is a quick-and-dirty, literate-programming-style documentation generator. It is a C# port of Docco [7]. Nocco produces HTML that displays your comments alongside your code. Comments are passed through Markdown, and code is highlighted using google-code-prettify syntax highlighting.

  • Visual Studio will generate XML some template documentation tags for you by typing /// at the beginning of the method, variable, etc.

  • Natural Docs [8]. Natural Docs is an open-source documentation generator for multiple programming languages. You document your code in a natural syntax that reads like plain English. Natural Docs then scans your code and builds high-quality HTML documentation from it.

  • NDoc3 [9] Notable mention -- but this project appears to be sort of extinct.

Non-Free Options

  • Document! X [10]. Document! X is a combination of an automated .NET documentation tool and a full documentation authoring environment which can be used to create accurate, professional quality dotnet documentation for assemblies created with any .NET language (C#, Visual Basic, C++/CLI etc.). (Starting at $468 USD)

  • VSdocman [11]. VSdocman is an ultimate API documenting tool for every Visual Studio developer - whether you create a class library, a component, a control, an application, a smart device or a web site (ASP .NET). (Starting at $229 USD per license)

  • Atomineer Pro [12]. This extension for Visual Studio provides unsurpassed code documentation comment generation and updating, smart word wrapping of text within comments, live typing aids to make editing comments much easier, tools to quickly convert legacy documentation to new formats, a command to instantly align code (such as assignments, parameters and tabular data) into columns, and several handy outlining, code generation and clipboard commands. (Starting at $40 USD per license)

  • TwinText [13]. Another code-comment HTML document generator. Doesn't require any special markup in the comments. Has easy customization of document appearance. ($169 USD per license)

  • Doc-O-Matic [14]. Takes source code and comments, adds conceptual topics and external input and produces documentation from it. Generates HTML Help, PDF, Help 2, Help 3 to Web Help and Windows Help. ($49 USD)

  • Live Documenter [15]. The Live Documenter isn't just another .NET documentation tool, it's different. It works by displaying the documentation live for your project. Rather than an old out of date static copy. Live Documenter lets you read your comments, like a book. Always straight from the press. (50£ GBP)

[1] https://github.com/EWSoftware/SHFB
[2] http://sandcastle.codeplex.com/
[3] http://www.roland-weigelt.de/ghostdoc/
[4] http://www.stack.nl/~dimitri/doxygen/
[5] http://docu.jagregory.com/
[6] http://dontangg.github.com/nocco/
[7] http://jashkenas.github.com/docco/
[8] http://www.naturaldocs.org/
[9] http://sourceforge.net/projects/ndoc3/
[10] http://www.innovasys.com/products/dx/dotnetdocumentation.aspx
[11] http://www.helixoft.com/vsdocman/overview.html
[12] http://www.atomineerutils.com/
[13] http://www.ptlogica.com/TwinText/
[14] http://www.doc-o-matic.com/
[15] http://theboxsoftware.com/products/live-documenter/

(7) Note that the free version of GhostDoc only comments code, and the pro (paid) version generates MSDN-style documentation. Useful to know if, like me, you're looking for a help file generator for an open source project. - cosmo0
@cosmo0 I discovered the same thing. This boosted SandCastle over GhostDoc for me. - crush
Yes but Sandcastle, besides being not supported anymore, cannot be integrated in a build process without installing it on the build server, which can be a no-go for some projects. Today I would go with Doxygen or Docu. - cosmo0
@cosmo0, SandCastle can be used on build server without installation, we do exactly that. Install it on some system, then copy installed binaries and other files. I think we actually use SandCastle Help File Builder and all it needs for xcopy deployment is SHFBROOT environment variable. - Constantin
1
[+94] [2009-03-13 03:27:19] CMS

I recommend you to give a look to SandCastle [1]. It generates class library documentation from .NET assemblies and the XML documentation files generated by the C# compiler. You may want to use the SandCastle GUI tools, SHFB [2] or DocProject [3] which will ease completely the document generation process.

Also give a look to the recommended and allowed XML tags [4].

Update: I agree with the Matt's comment, NDoc [5] is almost a dead project [6], and remember that you could use also the old XSLT way [7].

[1] http://sandcastle.codeplex.com/
[2] http://www.codeplex.com/SHFB
[3] http://docproject.codeplex.com/
[4] http://msdn.microsoft.com/en-us/library/5ast78ax.aspx
[5] http://ndoc.sourceforge.net/
[6] http://www.charliedigital.com/PermaLink,guid,95b2ab68-ba92-413a-b758-2783cde5df9c.aspx
[7] http://www.codeproject.com/KB/XML/XMLDocStylesheet.aspx

(5) NDoc is out of date, you should be using Sandcastle. There are various GUI frontends for Sandcastle, such as this one: codeplex.com/SHFB or this one: inchl.nl/SandcastleGUI - Matt Olenik
+1 for the nice collection of links. Tried to move the important pieces to the front for better readability. - David Schmitt
The heck... just tried SHFB and none of my methods have summaries or descriptions, even though they all have /// <summary> s. Probably a way to fix that, but these are stupid defaults. - mpen
(2) @Ralph You have to turn on the XML Documentation File in your Visual Studio project settings. Then add that XML file to your SHFB project. - mhenry1384
@mhenry1384: Yeah... I figured that out shortly after leaving that comment and getting even more frustrated with other tools. Didn't need to add the XML file to the project though...it figured that much out. Not entirely sure why the XML files are necessary though.. the comments get baked into the assembly no? Because they appear with intellisense, so they must be stored in there somewhere. - mpen
Sandcastle is okay, but it does not answer the ryeguy's question. What he is looking for is a tool to generate the actual documentation, not extract documentation and format it. - T.J.Kjaer
The Sandcastle project is no longer being supported by Microsoft. Eric Woodruff is now managing the project at Sandcastle Help File Builder, which was mentioned by Matt Olenik. - Ryan Kyle
The link to SandCastleGUI is broken and for sale. - Ryan Gates
2
[+92] [2009-03-13 03:27:32] Joey [ACCEPTED]

You can start a comment with /// right above a class or class member and VS will insert some template documentation tags for you.


Is there is any other technique which decides the '///' & its format like parameters, return type, other details and its format like changing /// to //******************* - Rahul Uttarkar
Rahul, if you mean whether you can use //***** instead of /// as marker for documentation comments (that'd be my guess from that sentence), then no. - Joey
The original question seemed like it was targeted at generating the documentation, at least to me; if you came here looking for that, see the next answer below, specifically, it looks like GhostDoc fits the bill. - BrainSlugs83
@BrainSlugs83: The title sounds like that, yes, but the text, especially the second sentence hints at what I answered. As for generating documentation comments, count me in the (maybe small) crowd of people who hate them with a passion. I consider generated documentation worse than no documentation at all, because it cannot tell you anything that isn't in the name or type already and because no tool will warn you about missing/incomplete documentation should you forget to change it. Documenting a method DoSomething as Dos the something as it's commonly done may be comical, but not helpful. - Joey
3
[+41] [2009-03-13 03:35:10] Ray

I quite like GhostDoc [1]

GhostDoc is a free add-in for Visual Studio that automatically generates XML documentation comments for C#. Either by using existing documentation inherited from base classes or implemented interfaces, or by deducing comments from name and type of e.g. methods, properties or parameters.

Basically it generates the /// comments above the methods, class, etc for you. They're not perfect but provide a good starting point.

[1] http://submain.com/products/ghostdoc.aspx

(21) I really disliked GhostDoc because it (can) serve as an excuse not to do the documentation correctly. - ullmark
(39) @ullmark - public void DataBind() - /// <summary>Datas the bind.</summary> - Chris S
(14) @Chris: To be fair, that method should probably be named BindData(). - mpen
(55) @Mark not if you're Yoda. - m4tt1mus
(13) Worse, it makes seem like your doing documentation when you are not. Even forward, the doc comment Binds Data on public void BindData() doesn't exactly give any new information does it? - George Mauer
The free version of GhostDoc does not produce MSDN-style documentation. That comes in the Pro version, which costs $50/user for personal, and strangely $80/user for commercial. - crush
public string firstName { get; set; } - /// <summary>Name of the first.</summery> - modiX
4
[+6] [2009-03-13 03:48:21] si618

As per Ray's suggestion, GhostDoc is handy, although it can lead to boilerplate docs without substance if developers are lazy.

Sandcastle [1] was originally supported by Microsoft, but is now maintained by SHFB [2]. You document using standard C# tags [3]. It has multiple output formats and plenty of flexibility. Just give whatever box you build docs on plenty of RAM.

I'd recommend SHFB to make life easy with Sandcastle. It's modeled after NDoc and works from a GUI or command line.

[1] https://sandcastle.codeplex.com/
[2] http://www.codeplex.com/SHFB
[3] http://msdn.microsoft.com/en-us/library/b2s063f7.aspx

5
[+6] [2009-03-21 13:35:46] James Gregory

As others have said, if you want to generate the comments in your code you should have a look at GhostDoc [1].

As for outputting the comments into something nice. I recently started an open-source project for generating documentation for .Net apps, as an alternative to Sandcastle. I don't want to get into the hows or whys I've done such a thing here, but you might want to check it out. It's early days yet, but it's making steady progress.

Docu - simple documentation done simply [2]

[1] http://www.roland-weigelt.de/ghostdoc/
[2] http://docu.jagregory.com

6
[+5] [2010-06-01 09:03:44] robasta

Now (over a year later) there is NDoc3 [1]. Very easy to use.

[1] http://sourceforge.net/projects/ndoc3

(7) Just tried it. Failed hard with .NET 4. - mpen
(1) Looking at the bug list, it still doesn't support generics correctly. And it hasn't been updated for a few months. - Barry Jones
7
[+5] [2012-03-14 09:50:50] MattyG

Doxygen [1] has been suggested in here [2]. Quoting Matt:

"Doxygen generates javadoc style documentation, although it looks like it's primarily intended to generate documentation from custom markup within your comments. Evidently, Doxygen also supports C# XML Comments... Anyway, I recommend it. It's easy to use, supports multiple languages and also generates class diagrams for you."

[1] http://www.stack.nl/~dimitri/doxygen/
[2] http://stackoverflow.com/a/51255/470879

8
[+4] [2009-06-30 14:56:09] Hace

GhostDoc is great, but I did have a rant about adding comments some time ago. If you are going to add comments, make them usefull! [1].

[1] http://www.mellekoning.nl/index.php/2009/03/16/comments-in-code-make-them-usefull/

9
[+4] [2012-10-04 22:48:56] rupertb

I used a tool on a clients site when I was contracting recently called Document! X [1] (by a company called Innovasys). It includes a nifty comment editor extension in Visual Studio - i.e. a WYSIWYG editor opens up that looks like the generated documentation, including any existing xml source comments and any edits you make in there are written back as source comments. It also built the final docs for us and they looked indistinguishable from regular MSDN and worked directly from F1 in Visual Studio.

[1] http://www.innovasys.com/products/dx/dotnetdocumentation.aspx

10
[+3] [2010-07-25 16:12:58] Barry Jones

Live Documenter [1] is a free documentation tool from The Box Software.

[1] http://theboxsoftware.com/products/live-documenter/

11
[+1] [2011-03-14 07:01:27] Vinod kumar kushawaha

Which command will cause an XML file to be generated from documentation comments?

Ans- csc MyClass.cs /doc:MyClass.xml.

To build the XML Documentation sample within Visual Studio In Solution Explorer, right-click the project and click Properties. Open the Configuration Properties folder and click Build. Set the XML Documentation File property to XMLsample.xml. On the Build menu, click Build. The XML output file will be in the debug directory.

To build the XML Documentation sample from the Command Line To generate the sample XML documentation, type the following at the command prompt:csc XMLsample.cs /doc:XMLsample.xm


12
[+1] [2012-08-23 13:18:33] Preben Huybrechts

I really like Nocco (.NET port of Docco). It provides you with a side by side view of your code and the comments. Nocco documentation [1] & Source [2]

[1] http://dontangg.github.com/nocco/
[2] https://github.com/dontangg/nocco

13
[+1] [2014-11-04 18:54:48] John Peters

Works Excellent for C# (Updated 11/04/2014)

I use SandCastleHelpFile builder. It allows you to use Code Commenting, producing XML comments from your compiles. From my perspective, there's no other tool I'm interested in (personally). This is because I've already spent the time learning it, and it's free. The setup wizard is excellent.

Here's the steps:

  1. Download and follow the install wizard from this site http://shfb.codeplex.com/
  2. Create a separate Visual Studio project of type SHFB as it will have installed a template.
  3. Point it to the Dlls OR even better the Solution files that you want documented. This assumes that you've already compiled these projects with XML options turned on, see Project Properties to turn on the XML options. This also assumes that the code has XML comments.
  4. You may add conceptual topics, images and many other decorations to the project output
  5. Project can output either Compiled Help Files or Web Sites that look exactly like .NET references on MSDN site.

Warning it will take you a bit of time to learn the tool and the AML (Application Markup Language). You will spend about a week learning and testing how it works. Make sure to document the namespaces and the class files too. You will want to investigate all the options and plug ins too.


14
[+1] [2014-11-05 22:44:30] SPBreed

With Visual Studio 2012 and 2013, Microsoft released a Nuget package for generating documentation for MVC and WebAPI projects.

Search "Microsoft.AspNet.WebApi.HelpPage" package by from Manage Nuget package or install using

For a C# application: Install-Package Microsoft.AspNet.WebApi.HelpPage

For a Visual Basic application: Install-Package Microsoft.AspNet.WebApi.HelpPage.VB

This create live documentation for all your controller definitions and classes defined in the input and output.

More on this here

http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages


15