Skip to navigation

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

<?doc-detective test {"testId": "my-test", "detectSteps": false} ?>
<?doc-detective step {"checkLink": "https://example.com"} ?>
<?doc-detective test end?>

YAML format

<?doc-detective test
testId: my-test
detectSteps: false
?>
<?doc-detective step checkLink: "https://example.com" ?>
<?doc-detective test end?>

XML attribute format

<?doc-detective test testId="my-test" detectSteps=false ?>
<?doc-detective step checkLink="https://example.com" ?>
<?doc-detective test end?>

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:

<!-- test testId="my-test" detectSteps=false -->
<!-- step checkLink="https://example.com" -->
<!-- test end -->

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:

<data name="doc-detective" value="test testId='my-test' detectSteps=false"/>
<data name="doc-detective" value="step checkLink='https://example.com'"/>
<data name="doc-detective" value="test end"/>

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:

<!-- Double quotes for attribute, single quotes for values -->
<data name="doc-detective" value="test testId='my-test'"/>
<!-- Single quotes for attribute, double quotes for values -->
<data name='doc-detective' value='test testId="my-test"'/>

Both self-closing tags and explicit closing tags work:

<!-- Self-closing -->
<data name="doc-detective" value="step goTo='https://example.com'"/>
<!-- With closing tag -->
<data name="doc-detective" value="step goTo='https://example.com'"></data>

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:

  • &#34; and &quot; become "
  • &#39; and &apos; become '
  • &lt; and &gt; become < and >
  • &amp; 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:

DefinitionDITA that matchesStep
clickUiControlClick the <uicontrol>Submit</uicontrol> button, or after “Tap”, “Select”, “Press”, or “Choose”click
typeIntoUiControlType <userinput>testuser</userinput> into the <uicontrol>Username</uicontrol> field, or after “Enter” or “Input”type into the control
goToUrlNavigate to <xref href="https://example.com">Example</xref>, and the other navigation verbsgoTo
findUiControlAny <uicontrol>find
verifyWindowTitleAny <wintitle>find
checkHyperlinkAny <xref> whose href is an http or https URLcheckLink
checkLinkElementAny <link> whose href is an http or https URLcheckLink
clickOnscreenTextClick <b>Save</b>, and the other click verbsclick
findOnscreenTextAny <b> textfind
typeTextType "kittens" in prosetype
screenshotImage<image href="results.png" outputclass="screenshot"/>screenshot
httpRequestFormatA <codeblock outputclass="language-http">, or one with no language, that holds a requesthttpRequest
runCodeA <codeblock> whose outputclass is language-bash, language-python, language-py, language-javascript, or language-jsrunCode, marked unsafe

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:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="create-user-account">
<title>Create a User Account</title>
<?doc-detective test testId="user-account-test" detectSteps=true ?>
<taskbody>
<context>
<p>This procedure shows how to create a new user account in the system.</p>
</context>
<steps>
<step>
<cmd>Navigate to <xref href="https://app.example.com/login" format="html" scope="external">the application</xref></cmd>
</step>
<step>
<cmd>Click the <uicontrol>Sign In</uicontrol> button</cmd>
</step>
<step>
<cmd>Type <userinput>admin@example.com</userinput> into the <uicontrol>Username</uicontrol> field</cmd>
</step>
<step>
<cmd>Type <userinput>password123</userinput> into the <uicontrol>Password</uicontrol> field</cmd>
</step>
<step>
<cmd>Press <shortcut>Enter</shortcut> to submit the form</cmd>
</step>
<step>
<cmd>Verify the <wintitle>Create User</wintitle> dialog appears</cmd>
</step>
</steps>
</taskbody>
<?doc-detective test end?>
</task>

Detected tests:

{
"tests": [
{
"testId": "user-account-test",
"steps": [
{ "goTo": "https://app.example.com/login" },
{ "checkLink": "https://app.example.com/login" },
{ "click": "Sign In" },
{ "find": "Sign In" },
{ "type": { "keys": "admin@example.com", "selector": "Username" } },
{ "find": "Username" },
{ "type": { "keys": "password123", "selector": "Password" } },
{ "find": "Password" },
{ "find": "Create User" }
]
}
]
}

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