Literate Programming in .NET

DevX has posted an article that I am really pretty proud of: a literate programming tool for .NET using Microsoft’s Visual Studio Tools for Office 2005. By using Word styles and embedding XML tags, you can label your code fragments in a Word document as compilable (including specifying assembly targets, compiler options, etc.). Additionally, the code fragments can have references to other code fragments within them, so that your code fragment can say “<<using block>>” and you can fill in those details someplace else in the document (in a separate discussion, an appendix, or even in a hidden “boilerplate“ section).

A SmartTag assembles all of the code fragments for a given “compilation unit,“ (think normal source code file) and all the “compilation unit“s for a given “assembly target.“ They source can be placed on the clipboard as an XML tree of fragments, as an assembled compilation unit (ready for pasting into Visual Studio), or can even be compiled directly from within Word. I support C# and VB.NET “out of the box“ but it’s a simple matter to support additional languages for compilation.

Normally, I’m content to write a tool for an article and leave it for as inspiration for further exploration by others, but I think this tool has such potential that I’m going to continue developing it, possibly on SourceForge or, more likely, hosted locally. In particular, I’d like to add FIT capabilities so that authors would have the ability to confirm that their code behaves as they expect; macros so that adding code blocks was as easy as “Ctl-C“ (or whatever); and the ability to specify “alternate fragments“ so that you can say “If we replace Listing 12 with Listing 13, you can see the behavior do such-and-so…“

I’m going to reveal a new site on the subject shortly…

 

Loren starts showing ink code comments

Loren Heiny is has begun posting screenshots from his work developing IDE plug-ins allowing inked comments to be made on source code. Personally, I think this is a tremendous use of the Tablet. DevX has just put up my article on literate programming in .NET using Word (in other words, a Word document whose code listings are supported by a “compile this!” smart tag). I was able to use Word’s ink annotation capabilities in that project, as well (especially when ink comments are set to “float in front” of the text), but Loren’s is definitely the more focused effort.