Widget Content From a File
In This Topic
Several of the standard Widget types allow you to use the content from an external file (e.g. a source code file) as the source in order to avoid duplicating content that already exists in source files. The Widget types that support using an external file as the source are:
- Colorized Example Code Section From File
- Colorized Example Code From File
- Colorized Example Code From File (Tab Style)
- Language Filtered Section From File
- Language Filtered Code Box From File
- Language Filtered Code Box From File (Tab Style)
Using Widget Content from an External Source File
- Open a Topic or Content File for edit.
- On the Content Authoring tab, click the Widget dropdown button.
- From the list of Widgets, choose a Widget Type from the list above.
- The Widget will be inserted into the active editor ready for you to fill in the Widget Properties.
- Type the name of the external source file you want to use as the content for this Widget in the File Name field. The path and filename can either be an absolute (fully qualified) path and filename (e.g. c:\myexamples\example1.cs) or a path relative to the project directory (e.g. examples\example1.cs).
- If your example file contains more than one named section, marked up using the section marking scheme outlined below, type the section name in the Section Name field.
- When you preview or build the output the Widget now derives its content from the external source file.
Marking Up One or More Named Regions Within a Source File
If you are using content from source files, you may wish to only use a portion of the file; for example if the source file is part of a complete sample project and contains code that is outside the scope of a specific example.
To use just a portion of a source file, you can mark up regions of the file using specifically formatted marker text to identify the start and end of a region, as well as the region name. By default the start marker should be of the format '#region {Name}#' or '#Region "{Name}"' where {Name} is the name of the region. The end region marker should be '#endregion' or '#End Region'. The start and end region markers can appear anywhere on a line, typically a comment line, so they can be used in any source file regardless of the language.
Here are a few examples of region markup:
The default format of start and end region markers can be customized in the Document! X and HelpStudio Bundle Options. For example, if you have an existing body of code with some other scheme in use to markup named regions of code.
See Also