Conditional content generation
By default, all topics and content created in an HelpNDoc project will be generated in every builds and documentation formats. It is possible to conditionally generate topics and content using build tags and conditions:
- Build tags represent unique identifiers which can be associated with a topic or a part of a topic
- Conditions are instructions indicating whether a section is included or not based on specific tags
Conditional topic generation
A topic can be included or not in specific builds based on build kind and build tags. By default a topic is included in all builds. To choose which build will include a topic, select the topic in the table of contents then:
- From the "Home" ribbon tab, click "Topic properties", then "Include in builds" and select each build kind and custom tag that applies
- Or right click on the topic and choose options in the "Include in builds" popup menu
See the How to setup conditional topic generation step-by-step guide.
Conditional content generation
HelpNDoc provides an easy way to define sections (parts of topics) which will only be included in specific builds using conditional sections. Those logical statements (If, Else If, Else, End) can be inserted within a topic using the "Insert" ribbon tab.
Using the "Insert conditional operation" dialog box, choose between one of the operations:
- IF: Start of a conditional section. The content written after this operation will be included only if the tags are included (IF) or not included (IF NOT) in the current build;
- ELSE IF: Adds an additional condition after an IF or another ELSE IF operation. The content written after this operation will be included only if the previous conditions were not matched and the specified tags are included (ELSE IF) or not included (ELSE IF NOT) in the current build;
- ELSE: Negates the previous IF or ELSE IF conditions. As an example, if the previous IF operation included "CHM and HTML", the ELSE operation will include everything except those;
- END: Closes the currently open conditional section. When conditional sections are nested, the END operation closes only the most recently opened IF / ELSE IF / ELSE block. Any content written after an END statement will continue using the parent condition, or will be included in all builds if no parent condition remains open.
To edit an existing conditional operation in the topic editor, double click the condition label. This will open the "Insert / Edit condition" dialog box, where you can modify the operation type, tags, and condition settings.
Warning: Starting with HelpNDoc 10.6, conditional content tags can now be nested. Because of this change, existing projects should be reviewed carefully. Previously, an IF condition that followed another IF condition was automatically interpreted as an ELSE IF. This is no longer the case. To help identify affected content, use the built-in project analyzer to locate conditional content throughout the project and verify that existing conditions still behave as intended.
See the How to setup conditional content generation step-by-step guide.
Define custom tags
To define custom tags, you can either:
- Right click on a topic, hover "Included in builds" then click "Manage build tags"
- From the "Generate help" window, select a build and click "customize" if the "Included tags" is not visible" then click "Manage tags"
See the How to manage build tags step-by-step guide.
Associate tags with builds
Each build can include one or more custom tag. To add custom tags to a specific build:
- Click the top part of the "Generate help" button in the "Home" ribbon tab
- Select a build
- Click "Customize" if the "Included tags" tab is not already visible
- Select the "Included tags" tab
- Check any custom tag that will be included in that build
See the How to maintain tags associated with output builds step-by-step guide.