Jan Schreuder on .Net

.Net code samples, experiences, observations

View my professional profile on LinkedIn

Recent Posts

Tags

News

  • Inappropriate comments will be deleted at my discretion.

    The information and code samples in this weblog is provided "AS IS" without warranty of any kind, either expressed or implied, including but not limited to the merchantability and/or fitness for a particular purpose.

Community

Email Notifications

Tool suppliers

Tools

General

Microsoft

Favorite blogs

Archives

GhostDoc - Generate documentation

In a previous post, I mentioned that I miss having a working version of NDoc for Visual Studio 2005. And I still do, but that doesn't stop me from documenting my code.

I recently installed Roland Weigelt's GhostDoc. It was featured in James Avery's MSDN article "10 Must-Have Add-Ins" and I thought I'd give it a go. A quote from the GhostDoc website:

GhostDoc is a free add-in for Visual Studio that automatically generates XML documentation comments. 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.

Take for example this method:

public SqlCommand BuildInsertCommand(DataTable dataTable)
{
    // Build the SqlCommand
}

When you add XML documentation using the standard method (by typing ///) you would get this:

/// <summary>
/// 
/// </summary>
/// <param name="dataTable"></param>
/// <returns></returns>
public SqlCommand BuildInsertCommand(DataTable dataTable)
{
    // Build the SqlCommand
}

But if you have GhostDoc installed, you simply right-click anywhere inside the method and you get this:

/// <summary>
/// Builds the insert command.
/// </summary>
/// <param name="dataTable">The data table.</param>
/// <returns></returns>
public SqlCommand BuildInsertCommand(DataTable dataTable)
{
    // Build the SqlCommand
}

You will see that a lot of stuff is already there. Based on the method name, it already entered a short description. All you need to do is check (and possibly improve) that descrition, explain a bit more on what the parameters are for and add stuff that you think is missing. If this method implements an existing interface, or was used to override a member of an inherited class, GhostDoc would have retrieved the documentation for that member. 

The version for Visual Studio 2003 only supports C# code, but the version for Visual Studio 2005 also works on VB.Net. Although Roland still say's that VB.Net support is experimental.

Here are some more links on GhostDoc I found at Roland's website:

All I need now is a working version of NDoc 2005. A Beta is available at SourceForge, but I can't get it to work. It claims it is missing xslt files. Guess I'll have to wait for the final version.

Comments

Marc Jacobi said:

I also tried GhostDoc but I was only pleased with the feature that retrieves "derived" documentation. The text it generates is not really usefull documentation, at least I don't consider "The data table" usefull ;-).

Bottom line is that the documentation you really want to read as a user of your code is hard to write as a Human and I dont think we're long of automating that.

If code comments are not reviewed on their contents, than GhostDoc is the tool for you!

-Marc Jacobi
# June 23, 2006 2:42 AM

Jan Schreuder said:

Marc, you're right ofcourse that comments like "The data table" are not useful. As I said, you need to add a bit more information to the stuff generated. And as you said, it's great when it is able to get "derived" documentation. It's equally great when documenting properties, at least I think so.

I'm sorry to say, but you're comment "If code comments are not reviewed on their contents, than GhostDoc is the tool for you!" sounds a bit disappinting. Yes, code comments could benefit from reviews. But that goes for comments created using the help from GhostDoc as for the stuff added by more or less "intelligent" developers.

It's still up to the developer to write something useful. GhostDoc is a tool to help you create documentation and create the obvious stuff.

# June 23, 2006 4:50 AM

Nathan Pledger said:

The way I see it is some documentation is better than none, even if it is stating the obvious. And besides, if your good at your functional programming, it should be pretty obvious what is going on anyway.

I installed it and really like it. Does away with typing the same old things again and again.
# June 23, 2006 5:19 AM

Dennis van der Stelt said:

I don't get what this tool gives you more than the standard /// in VS2003 and 2005.

First of, the function your writing not only builds the insert command, it also returns this. So I'd rename the function to GetInsertCommand or something. GhostDoc will probably say "Get Insert Command". What's the benefit of that over the current method name?!

Same goes for "The data table". One of the reasons for loosing notation where you'd specifiy the type (as in strMyString and blnChecked) was because we can see the type when hovering over it. What's the use of some comment saying "Dude! Hey, check this! I'm returning a data table here! Oh, yeah, I know, you can see that in the exact same tooltip as where you're reading this sentence, but hey, I'm generated with GhostDoc and this is just what I generate!"

If it's in the top 10 must have addins, I don't even want to take a look in that list! :)
# June 23, 2006 1:30 PM

P.J. van de Sande said:

It isn't for nothing that this tool had the first price in Roy's Addin Contest.

There is one point that Dennis forgot, document generation for method overrides. When you implement and method defined in a interface, the documentation from the interface method sig will copied. This is a very great function, i write the documention above the method sig's in the interface. And every implementor can just copy the documentation with GhostDoc and only add the and exception inforomation or some extra information if needed.
Only for this future i will recomment GhostDoc!
# June 26, 2006 4:56 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 7 and 3 and type the answer here: