This build component is used to search for <code> XML comment tags and colorize the code within them. It can also include code from an external file or a region within the file.

Namespace: SandcastleBuilder.Components
Assembly: SandcastleBuilder.Components (in SandcastleBuilder.Components.dll) Version: 1.9.0.0

Syntax

C#
public class CodeBlockComponent : BuildComponent
Visual Basic
Public Class CodeBlockComponent _
	Inherits BuildComponent

Remarks

Note that this component must be paired with the PostTransformComponent.

Examples

CopyExample configuration
<!-- Code block component configuration.  This must appear before
     the TransformComponent.  See also: PostTransformComponent. -->
<component type="SandcastleBuilder.Components.CodeBlockComponent"
  assembly="C:\SandcastleBuilder\SandcastleBuilder.Components.dll">
    <!-- Base path for relative filenames in source
         attributes (optional). -->
    <basePath value="..\SandcastleComponents" />

    <!-- Connect to language filter (optional).  If omitted,
         language filtering is enabled by default. -->
    <languageFilter value="true" />

    <!-- Allow missing source files (Optional).  If omitted,
         it will generate errors if referenced source files
         are missing. -->
    <allowMissingSource value="false" />

    <!-- Remove region markers from imported code blocks.  If omitted,
         region markers in imported code blocks are left alone. -->
    <removeRegionMarkers value="false" />

    <!-- Code colorizer options (required).
      Attributes:
        Language syntax configuration file (required)
        XSLT style file (required)
        "Copy" image file URL (required)
        Default language (optional)
        Enable line numbering (optional)
        Enable outlining (optional)
        Keep XML comment "see" tags within the code (optional)
        Tab size for unknown languages (optional, 0 = use default)
        Use language name as default title (optional) -->
    <colorizer syntaxFile="highlight.xml" styleFile="highlight.xsl"
      copyImageUrl="CopyCode.gif" language="cs" numberLines="false"
      outlining="false" keepSeeTags="false" tabSize="0"
      defaultTitle="true" />
</component>
CopyExamples as used in XML comments.
<example>
A basic code block that uses the configuration defaults:
<code>
/// Code to colorize
</code>

Override options with block-specific options:
<code lang="xml" numberLines="true" outlining="false" tabSize="8" >
    &lt;XmlTags/&gt;
</code>

An entire external file or a delimited region from it can be
included.  This allows you to compile your example code externally
to ensure that it is still valid and saves you from maintaining it
in two places.

Retrieve all code from an external file.  Use VB.NET syntax.
<code source="..\Examples\WholeDemo.vb" lang="vbnet"/>

Retrieve a specific #region from an external file.
<code source="..\Examples\SeveralExamples.vb"
    region="Example 1" lang="vbnet"/>

Keep <see> tags within comments so that they are converted to
links to the help topics.
<code keepSeeTags="true">
int x = this.<see cref="CountStuff">CountStuff</see>(true);

string value = this.<see cref="System.Object.ToString">
<code>

<example>

Inheritance Hierarchy

System..::..Object
  Microsoft.Ddue.Tools..::..BuildComponent
    SandcastleBuilder.Components..::..CodeBlockComponent

See Also