You are here: Documenting Your Class Library with Microsoft® Sandcastle > CodeBlock and PostTransform components

CodeBlock and PostTransform components

The Doc-to-Help Sandcastle plugin includes Eric Woodruff's components (with his permission) that complement Sandcastle functionality for better display of code blocks in various languages, including syntax highlighting andconnecting code blocks to the language filter. Normally, you don't need to change the settings for those components, but the XML source document's Properties dialog box allows you to do so, in the Components tab of the Output node.

For a complete description of those components, see Eric Woodruff's article "Creating Custom Build Components for Sandcastle" at http://www.codeproject.com/csharp/SandcastleComponents.asp.

Here is an excerpt from that article listing the features of the CodeBlock component:

      Excess leading whitespace is stripped from the <code> blocks to left-align them correctly.

      Support for optional line numbering.

      Support for optional collapsible regions for code in #region and #if/#else/#endif blocks with support for nested collapsible regions. The VB.NET equivalents are supported also.

      A default title can be added based on the language that the code represents.

      A "Copy" link appears to the right on the title line that allows you to copy the code sample to the clipboard (Internet Explorer only). The code is copied as plain text without the highlighting and line numbers if used.

      Adds support for reading in an external source file or a defined region of an external source file so that you can keep code samples in a buildable project to test them for correctness and to do away with managing the code samples in the XML comments or include files.

      C#, VB.NET, C++, and J# code blocks can be associated with the language filter to show or hide them based on the language filter setting.

      Syntax highlighting of code blocks in <code> tags. Languages supported include C#, VB.NET, C++, J#, C, JavaScript, VBScript, and XML. An external configuration file is used so that it is possible to extend the colorizer to support other languages. The stylesheet is also replaceable.