DITA input format
Beta: DITA markup patterns are available in beta and subject to change.
DITA (Darwin Information Typing Architecture) is an XML-based format for technical documentation. Doc Detective supports DITA task topics and can extract tests from semantic markup elements.
File extensions
Doc Detective processes DITA files with the following extensions:
.dita.ditamap.xml
Inline test syntax
DITA files use XML processing instructions or HTML comments to define inline tests. Processing instructions must start with <?doc-detective for Doc Detective to recognize them.
JSON format
YAML format
XML attribute format
Attribute values are automatically converted to the appropriate type: booleans (detectSteps=false), numbers (wait=500), and strings. You can use dot notation for nested objects. For example, <?doc-detective step httpRequest.url="https://api.example.com" httpRequest.method="GET" ?>.
HTML comment syntax
You can also use HTML comment syntax as an alternative:
HTML comments and processing instructions work identically. Use whichever fits your workflow better.
DITA data element syntax
DITA <data> elements let you define inline tests using standard DITA markup:
Set the name attribute to doc-detective and put the test or step declaration in the value attribute. You can use single or double quotes for either attribute:
Both self-closing tags and explicit closing tags work:
Use <data> elements when you want tests that validate with DITA-aware tools, or when your publishing workflow filters out processing instructions.
XML entity decoding
DITA OT and other XML processors encode reserved characters in attribute values. Doc Detective decodes these entities before parsing:
"and"become"'and'become'<and>become<and>&becomes&
Tests defined in your source files work correctly after DITA OT processing, even when the output contains encoded entities.
Detected tests
With step detection on, DITA files detect the steps listed in What gets detected, and use DITA’s semantic elements for more:
A <codeblock> takes its language from a language-x value in outputclass, as DITA-OT’s syntax highlighting does. Statements and tags inside <codeblock>, <codeph>, <pre>, <screen>, and <msgblock> aren’t read.
The verb patterns match the source right before the element, inline tags included, from the start of its block, such as <cmd> or <p>. A <uicontrol> after “Click the” gets both a click and a find step. A <uicontrol> after a Type <userinput> phrase gets both a type and a find step.
Best practices:
- Use semantic DITA elements, such as
<uicontrol>and<userinput>, for accurate detection. - Structure procedures as DITA task topics, with
<steps>and<cmd>elements. - Set
outputclass="language-x"on<codeblock>elements to name their language. - Combine inline processing instructions with detected tests for full coverage.
Other elements, such as <menucascade>, <systemoutput>, and <cmdname>, don’t produce steps on their own. To detect them, add a selector for the element. For every option, see the configuration reference.
Example with detected tests
DITA task topic:
Detected tests:
The Press <shortcut>Enter</shortcut> step has no default definition. To type it, add an inline step, or a selector for <shortcut>.
Loading DITA content from Heretto
If you manage your DITA content in Heretto, Doc Detective can load it directly from your Heretto CCMS. See Heretto integration for configuration details.
Next steps
- Learn about inline tests for manual test definition
- Learn about detected tests for automatic test generation
- See custom inputs to extend DITA patterns
- See Heretto integration to load DITA content from Heretto CCMS