BrianPeek.com

A Compendium of Random Uselessness
in Search
  • Sandcastle and API Documentation

    I've received a few emails recently on how I created the API documentation for my Wiimote library so I thought I'd answer here with a brief tutorial.

    The answer, in case you didn't read the post subject, is Sandcastle.  Sandcastle is a tool developed by Microsoft which builds MSDN-style help files by using reflection and XML comments from the source code of a project.  Out of the box, Sandcastle is command line driven and kind of a pain to deal with, so I highly recommend the very easy to use Sandcastle Help File Builder (SHFB) application also hosted on CodePlex.  This front-end provides a simple UI for setting options and building your help file in just a few minutes.  The rest of this post assumed you have both Sandcastle and Sancastle Help File Builder installed.

    Building documentation is easy.  First, add XML documentation comments directly to your source code.  You can do this by typing 3 forward slashes in Visual Studio above your class/method/type/property/etc. and the IDE will fill in the documentation template.  For example, if you had a method definition which looked like this:

    public int DoSomething(string s, bool b)

    and you typed /// above the method name, Visual Studio would generate the following:

    /// <summary>
    /// 
    /// </summary>
    /// <param name="s"></param>
    /// <param name="b"></param>
    /// <returns></returns>
    public int DoSomething(string s, bool b)
     

    At this point, it is your responsibility to fill in the tags which were generated.  Also note that there are a variety of other tags that can be added to provide additional information in the documentation output, such as a code sample, links to other documentation, etc.  You can find a list of all documentation tags here.

    After the XML documentation is created, you must tell the compiler to generate the output XML documentation file.  In Visual Studio, this can be done by going to the project's properties, selecting the Build tab, checking the "XML Documentation File" checkbox and providing an output filename.

    output

    When the project is compiled, you will now find that XML file in the path given.  By itself the file is pretty much useless, but it will allow Sandcastle to generate everything it needs to know about your project.

    To generate the documentation, Open Sandcastle Help File Builder and choose New Project from Visual Studio Project from the Project menu.  Locate your Visual Studio solution or project file and select it.  This will create a default Sandcastle configuration which will import your generated XML file and the associated assembly file(s) which will be pulled apart using reflection.  At this point, you can simply select Build Project from the Documentation menu and an HTML Help 1.0 CHM file will be created with the default Sandcastle settings.

    Sandcastle Help File builder allows a variety of customization options to be set for your generated documentation and it's worth going through what's available in the UI to create the documentation you require.  The UI itself documents every setting so creating what you need is amazingly easy.  For example, in my Wiimote documentation, I set the PresentationStyle to vs2005, change the copyright text fields, feedback email, etc. to create a custom-tailored set of docs for my library.

    Another great feature is the ability to add additional custom content to the generated documentation.  I add some additional pages which provide a general overview to the library and copyright/license information.  To add additional content, create a new directory and add .topic files to it.  Each .topic file is simply an XML file which gets passed through a transformation by SHFB that matches the chosen presentation style.  The base schema looks like the following:

    <?xml version="1.0" encoding="utf-8"?>
    
    <!DOCTYPE bodyText [ <!ENTITY nbsp "&#160;"> ]>
    
    <topic xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
        <!-- The page title -->
        <title>My Title</title>
        <!-- The body text for the topic -->
        <bodyText>
    Some body text<br/>
    And some more
        </bodyText>
    </topic>
    

    The full list of tags can be found in the SHFB documentation, but the above example is enough to create a page which will mirror the generated documentation style.  Simply fill in the <title> tag and the <bodyText> file, and save the .topic file.

    To add these .topic files to the generated documentation, select the AdditionalContent line item in SHFB and then click the ... button.  In the Additional Content Items dialog, click the Add folder icon in the lower left corner, and located the directory which contains the .topic files created above.  Then, click the Site Map button to arrange the order, indentation, etc. of the additional pages.

    additional

    Once the order is set in the Site Map dialog, click the Save button to save a .sitemap file.  This will be used by SHFB builder to determine where these entries are placed in the output file.  You will notice that the ContentSiteMap entry in the SHFB UI will point to the .sitemap file just created.  Build the project in SHFB again and you will now have documentation with the additional content added as you specified.

    And there you have it.  MSDN-style documentation generated with minimal effort.  I have only covered the basics here, so be sure to read through the documentation provided by all of these tools so you're aware of everything that is possible in creating documentation for your projects.

    Posted Feb 24 2008, 01:45 PM by Brian Peek with 2 comment(s)
    Filed under: ,

  • Tech Valley User Group Session Posted

    I have posted the slide deck and sample code from my "Interfacing External Hardware Using Managed Code" session that I gave earlier this evening.  I hope everyone that attended enjoyed the presentation and got something useful out of it.  Other than the RFID hardware failing for the 2nd time on me, I thought it went well.  If you have any questions or comments, fire them over to me.

    Posted Feb 19 2008, 10:10 PM by Brian Peek with no comments
    Filed under: ,

  • TVUG Session Rescheduled

    For all 0 of you planning on attending my session at the Tech Valley User Group tonight, please note that it has been rescheduled to next Tuesday, February 19 at 6:30pm due to the impending storm...

    Posted Feb 12 2008, 02:06 PM by Brian Peek with no comments
    Filed under: , ,

  • WiimoteLib Survey Results

    Once again, a bit thank you to all of you who took the time to respond.  I was amazed to receive 100 responses as quickly as I did.  So here are the results and a few comments.

    1. What type of release schedule would you prefer?

    Response

    Response Percent

    Response Count

    Frequent, small updates

    59.1%

    55

    Infrequent, large updates (what I have been doing so far)

    40.9%

    38

     

    2. I broke backward compatibility between version 1.1 and 1.2. I'm looking to do it again by cleaning up various things such as:

    • Moving anything with an X/Y coordinate to a Point struct
    • Since there are now 4 IR points all with the same properties (X, Y, MidX, etc.), I'd like to turn an IR itself into a struct, thereby having 4 IR structs in the IRState struct instead of the mish-mash of properties
    • And anything else I haven't thought of or mentioned here...

    How important is backward compatibility to you?

    Backward compatibility is for chumps...clean it up!

     

    I'm indifferent

     

    It absolutely, positively must be backward compatible to v1.2

    Rating
    Average

    Response
    Count

    45.3%
    (43)

    14.7%
    (14)

    25.3%
    (24)

    8.4%
    (8)

    6.3%
    (6)

    2.16

    95

     

    3. I don't use CodePlex for source control so it is never an active repository of the "work in progress". It is only updated at release with the same source that's provided in the .zip file. As long as I provide full source with every release, do you care about having the source code in the CodePlex source control server in addition to the .zip'ped source?

    Response

    Response Percent

    Response Count

    Yes

    46.9%

    46

    No

    53.1%

    52

     

    As for write in comments, I had quite a few people ask for multiple Wiimote support.  It's coming.  And my favorite comment from the 31 write-ins:  "poop".

    So what does it all mean?

    I guess it means that:

    • I'll try to start doing more frequent updates with less changes.
    • Backward compatibility apparently is for chumps and I'll definitely be cleaning up some of the ugliness in the code.
    • While not a victor, it's important enough to a lot of people that I'll continue to wedge source code into CodePlex with each new release.

    I'm working on a few new features with the library and hopefully will have a version 1.3 up soon.  Stay tuned...

    Posted Feb 11 2008, 02:22 PM by Brian Peek with no comments
    Filed under: ,

  • Tech Valley .NET Users Group Session

    UPDATE: This event has been rescheduled to Tuesday, February 19 at 6:30pm due to the weather.

    For those of you in the Capital District region of NY like myself, I'll be giving a session on how to interface external hardware using .NET at the Tech Valley .NET User Group on Tuesday, February 12 at 6:30pm.  Here's my poorly written blurb on the subject:

    While developers write code to build software every day, not often are they exposed to code that drives and interfaces hardware. This session will attempt to bridge that gap and show how .NET can be used to effectively interface several hardware devices, including an RFID reader and tags, Phidget control boards with a variety of sensors, and a servo controller. Finally, the Nintendo Wiimote will be introduced along with my .NET Wiimote Library, demonstrating how to connect to a USB or Bluetooth HID device and use it from .NET, with examples showing what the Wiimote itself is capable of.

    If you're in the area, please stop by and heckle!

    Posted Feb 07 2008, 05:36 PM by Brian Peek with no comments
    Filed under: , ,

  • WiimoteLib Survey

    Update:  Wow!  In just over a week I reached Survey Monkey's limit of 100 responses for the survey.  I'll be posting results soon.  Thanks to everyone who took the time to give me their feedback!

    For those of you that use my Managed Wiimote Library (and if you're not, why aren't you?), I've put together a very short, 3 question survey to gather some opinions on how to move forward with upcoming releases.  Please take the 30 seconds to click responses to the 3 multiple choice questions and let me know how you'd like to see the library evolve.  Thanks!

    Click here to take the survey!
    Posted Feb 01 2008, 03:09 AM by Brian Peek with 5 comment(s)
    Filed under: , ,

Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems