Skip to navigation

Formats, written as tests

Doc Detective reads the same tests and detects the same kinds of steps in every format. What changes is the syntax: where a statement goes, how you mark a code block, and which markup detection reads. Each example below uses one format and several of its syntax variants. Its inline variants still resolve to the same steps as its standalone spec. For what each tab holds, see Navigation and interaction.

Statements at a glance

A statement is the keyword test, step, test end, test ignore start, or test ignore end, inside a comment. The test and step keywords take a JSON object, a YAML mapping, or XML-style attributes such as find="Save". A YAML statement on one line holds one key, or a flow mapping such as {testId: my-test, detectSteps: false}.

FormatExtensionsStatement syntax
Markdownmd, markdown, mdx<!-- … -->, {/* … */}, and [comment]: # (…), [comment]: # '…', or [comment]: # "…"
AsciiDocadoc, asciidoc, asc// (…) on one line, or (…) inside a //// comment block
HTMLhtml, htm<!-- … -->
reStructuredTextrst.. … comment, with a blank line before and after. An indented block below continues it.
DITAdita, ditamap, xml<?doc-detective … ?>, <!-- … -->, and <data name="doc-detective" value="…"/>

A comment can span lines in every format. Doc Detective doesn’t read a statement inside a code block or inline code, so a page can show a statement without running it.

Default detection by format

With detection on, each format turns the same kinds of markup into steps. For the full list, see What gets detected.

StepMarkdownAsciiDocHTMLreStructuredTextDITA
goTo and checkLink[text](https://…)https://…[text], link:https://…[text]<a href="https://…">`text <https://…>`_<xref href="https://…">
click and find**text***text*, **text**<strong>, <b>**text**<b>, <uicontrol>
screenshot![alt](path){.screenshot}role=screenshotclass="screenshot":class: screenshotoutputclass="screenshot"
httpRequest```http[source,http]class="language-http".. code-block:: httpoutputclass="language-http"
runCode```bash[source,bash]class="language-bash".. code-block:: bashoutputclass="language-bash"
Keep a code block from running```bash testIgnore[source,bash,testIgnore]An ignore block:class: testIgnoreAn ignore block

In every format, a link right after a navigation verb, such as “Go to,” also becomes a goTo step. Bold text right after a click verb, such as “Click,” also becomes a click step. Quoted text after “Type,” “Enter,” or “Press” becomes a type step.

DITA also reads its semantic elements. A <uicontrol> becomes a find step, and after a click verb, a click step too. A <uicontrol> after a Type <userinput>…</userinput> into the phrase becomes a type step into that control. A <wintitle> becomes a find step, and a <link> to a web URL becomes a checkLink step.

HTML and DITA code blocks carry no testIgnore marker, so wrap a code block you don’t want to run in an ignore block.

Echo text in .md and .mdx files

This procedure uses goTo, click, type, and find. The Markdown file uses each [comment]: # form, an HTML comment with a YAML body, and an HTML comment that spans lines. The MDX file uses {/* */} comments the same way.

prose.md
# Echo text back
1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Markdown".
4. Check that the page shows **Hello, Markdown** below the field.
To fetch the page from a terminal instead, run:
```bash testIgnore
curl http://localhost:8092/type-echo.html
```
To start over, go to [the elements demo](http://localhost:8092/index.html).
  • A [comment]: # statement is a Markdown link reference definition, so it needs a blank line before it. Inside a list item, indent it to the item’s text.
  • Its body can sit in parentheses, single quotes, or double quotes. Inside double quotes, use YAML, as in [comment]: # "step type: Hello, Markdown", because a JSON object holds double quotes.
  • MDX builds fail on HTML comments, so an .mdx page uses {/* */} or [comment]: # statements.
  • ```bash testIgnore keeps the curl block from becoming a runCode step. The ignore block keeps the link to the elements demo from becoming goTo and checkLink steps.

What detection finds

The link becomes a goTo step and a checkLink step. Type here: becomes a click step and a find step. The quoted text becomes a type step, and Hello, Markdown becomes a find step.

Create a user in AsciiDoc

This procedure uses httpRequest. The test statement is a YAML flow mapping. One step spans several lines in a //// comment block, and the rest are // (…) line comments.

prose.adoc
= Create a user
To create a user, send this request:
[source,http]
----
POST http://localhost:8092/api/users
Content-Type: application/json
{"name": "Grace"}
----
To send the same request from a terminal, run:
[source,bash,testIgnore]
----
curl -X POST -H "Content-Type: application/json" -d '{"name": "Grace"}' http://localhost:8092/api/users
----
To rename the user later, send this request:
[source,http]
----
PUT http://localhost:8092/api/users/grace
Content-Type: application/json
{"name": "Grace Hopper"}
----
  • A // comment counts only at the start of a line, and its statement sits in parentheses.
  • In a //// block, the whole block is the statement, so a long step can span lines.
  • [source,bash,testIgnore] keeps the curl listing from becoming a runCode step. The ignore block skips the rename request.

What detection finds

The [source,http] listing becomes an httpRequest step with the listing’s method, URL, header, and body. Detection doesn’t add the response check, so the inline and standalone variants hold it.

Press a button in HTML

This procedure uses goTo, find, and click. The statements use a JSON body, a YAML body, XML-style attributes, and a comment that spans lines.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Press a button</title></head>
<body>
<h1>Press a button</h1>
<ol>
<li>Go to <a href="http://localhost:8092/index.html">the elements demo</a>.</li>
<li>Find the <strong>Buttons</strong> section.</li>
<li>Click <strong>Standard Button</strong>.</li>
</ol>
<p>To fetch the page from a terminal instead, run:</p>
<pre><code class="language-bash">curl http://localhost:8092/index.html</code></pre>
</body>
</html>
  • HTML reads statements only from <!-- --> comments.
  • A <code class="language-bash"> block has no testIgnore marker, so the ignore block keeps the curl block from becoming a runCode step.

What detection finds

The link becomes a goTo step and a checkLink step, and Buttons becomes a find step. After “Click,” Standard Button becomes a click step and a find step.

Look up a user in reStructuredText

This procedure uses checkLink and httpRequest. The statements use a JSON body, a YAML body, and a step that continues on the indented lines below .. step.

prose.rst
Look up a user
==============
#. Check that `the API <http://localhost:8092/status/200>`_ answers.
#. Send this request:
.. code-block:: http
GET http://localhost:8092/api/users?name=Linus
#. To send the same request from a terminal, run:
.. code-block:: bash
:class: testIgnore
curl "http://localhost:8092/api/users?name=Linus"
To browse the demo pages, go to `the elements demo <http://localhost:8092/index.html>`_.
  • Put a blank line before and after each statement. A .. line that continues a paragraph is prose, not a comment.
  • A comment holds its first line and the indented block below it, so a long step can span lines.
  • :class: testIgnore keeps the curl block from becoming a runCode step. The ignore block skips the link to the elements demo.

What detection finds

The link becomes a checkLink step. “Check that” doesn’t open a link, so there’s no goTo step. The http code block becomes an httpRequest step. Its URL keeps the query string. Detection doesn’t add the response check, so the inline and standalone variants hold it.

Echo text in DITA

This procedure uses goTo, click, type, and find. The statements use each DITA form. Processing instructions hold a JSON body, a YAML body across lines, and XML-style attributes. HTML comments hold an attribute step and the test end statement. The <data> elements use single and double quotes, and one has a closing tag.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="echo-text-dita">
<title>Echo text back</title>
<taskbody>
<steps>
<step><cmd>Go to <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref>.</cmd></step>
<step><cmd>Click <uicontrol>Type here:</uicontrol>.</cmd></step>
<step><cmd>Type "Hello, DITA".</cmd></step>
<step><cmd>Check that the page shows <b>Hello, DITA</b> below the field.</cmd></step>
</steps>
<postreq>
<p>To fetch the page from a terminal instead, run:</p>
<codeblock outputclass="language-bash">curl http://localhost:8092/type-echo.html</codeblock>
</postreq>
</taskbody>
</task>
  • A processing instruction starts with <?doc-detective.
  • A <data> element’s name is doc-detective, and its value holds the statement. Use one kind of quote for the attribute and the other inside it. Use <data> elements when your publishing workflow drops processing instructions, or when DITA-aware tools validate your topics.
  • XML-style attributes take dot notation for nested fields, as in httpRequest.url="…" httpRequest.method="get", and convert true, false, and numbers.
  • A <codeblock> has no testIgnore marker, so the ignore block keeps the curl block from becoming a runCode step.

What detection finds

The <xref> becomes a goTo step and a checkLink step. After “Click,” the <uicontrol> becomes a click step and a find step. The quoted text becomes a type step, and the <b> text becomes a find step. For more DITA detection, see DITA.

Ways to write a statement in Markdown

Each example checks two links, with every statement in one form. These examples have prose and inline variants only.

<!-- --> with a JSON body

Varies: statement form · Value: <!-- step {"checkLink": "…"} --> · Effect: the form Doc Detective writes back in .md files.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

<!-- --> with a YAML body

Varies: statement body · Value: <!-- step checkLink: … --> · Effect: a one-key step reads as YAML. A test with several keys uses a flow mapping.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

<!-- --> with attributes

Varies: statement body · Value: <!-- step checkLink="…" --> · Effect: each XML-style attribute becomes a field. false and numbers convert to their types.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

<!-- --> across lines

Varies: statement layout · Value: a comment that spans lines · Effect: the keyword and its body can sit on separate lines.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

[comment]: # ( )

Varies: statement form · Value: [comment]: # (step {…}) · Effect: a link reference definition, which Markdown leaves out of the page, with the statement in parentheses.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

[comment]: # ' '

Varies: statement form · Value: [comment]: # 'step {…}' · Effect: single quotes leave the JSON body’s double quotes free.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

[comment]: # " "

Varies: statement form · Value: [comment]: # "step checkLink: …" · Effect: double quotes can’t hold a JSON body, so the statements use YAML.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

Ways to write a statement in MDX

“ with a JSON body

Varies: statement form · Value: “ · Effect: the form Doc Detective writes back in .mdx files.

prose.mdx
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

“ with a YAML body

Varies: statement body · Value: “ · Effect: a one-key step reads as YAML.

prose.mdx
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

“ across lines

Varies: statement layout · Value: a JSX comment that spans lines · Effect: the keyword and its body can sit on separate lines.

prose.mdx
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

[comment]: # ' ' in an MDX file

Varies: statement form · Value: [comment]: # 'step {…}' · Effect: works in MDX too, where HTML comments break the build.

prose.mdx
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
2. Check that [the type echo page](http://localhost:8092/type-echo.html) loads.

Ways to write a statement in AsciiDoc

// ( ) with a JSON body

Varies: statement form · Value: // (step {…}) · Effect: the statement sits in parentheses in a // comment at the start of a line.

prose.adoc
= Check the demo pages
. Check that http://localhost:8092/index.html[the elements demo] loads.
. Check that http://localhost:8092/type-echo.html[the type echo page] loads.

// ( ) with a YAML body

Varies: statement body · Value: // (step checkLink: …) · Effect: a one-key step reads as YAML, and the test uses a flow mapping.

prose.adoc
= Check the demo pages
. Check that http://localhost:8092/index.html[the elements demo] loads.
. Check that http://localhost:8092/type-echo.html[the type echo page] loads.

//// block across lines

Varies: statement form · Value: a //// comment block · Effect: the whole block is the statement, so a step can span lines.

prose.adoc
= Check the demo pages
. Check that http://localhost:8092/index.html[the elements demo] loads.
. Check that http://localhost:8092/type-echo.html[the type echo page] loads.

Ways to write a statement in HTML

<!-- --> with a JSON body in HTML

Varies: statement body · Value: <!-- step {"checkLink": "…"} --> · Effect: the form Doc Detective writes back in HTML files.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Check the demo pages</title></head>
<body>
<h1>Check the demo pages</h1>
<ol>
<li>Check that <a href="http://localhost:8092/index.html">the elements demo</a> loads.</li>
<li>Check that <a href="http://localhost:8092/type-echo.html">the type echo page</a> loads.</li>
</ol>
</body>
</html>

Comment with a YAML body

Varies: statement body · Value: <!-- step checkLink: … --> · Effect: a one-key step reads as YAML, and the test uses a flow mapping.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Check the demo pages</title></head>
<body>
<h1>Check the demo pages</h1>
<ol>
<li>Check that <a href="http://localhost:8092/index.html">the elements demo</a> loads.</li>
<li>Check that <a href="http://localhost:8092/type-echo.html">the type echo page</a> loads.</li>
</ol>
</body>
</html>

<!-- --> with attributes in HTML

Varies: statement body · Value: <!-- step checkLink="…" --> · Effect: each XML-style attribute becomes a field.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Check the demo pages</title></head>
<body>
<h1>Check the demo pages</h1>
<ol>
<li>Check that <a href="http://localhost:8092/index.html">the elements demo</a> loads.</li>
<li>Check that <a href="http://localhost:8092/type-echo.html">the type echo page</a> loads.</li>
</ol>
</body>
</html>

<!-- --> across lines in HTML

Varies: statement layout · Value: a comment that spans lines · Effect: the keyword and its body can sit on separate lines.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Check the demo pages</title></head>
<body>
<h1>Check the demo pages</h1>
<ol>
<li>Check that <a href="http://localhost:8092/index.html">the elements demo</a> loads.</li>
<li>Check that <a href="http://localhost:8092/type-echo.html">the type echo page</a> loads.</li>
</ol>
</body>
</html>

Ways to write a statement in reStructuredText

.. with a JSON body

Varies: statement body · Value: .. step {"checkLink": "…"} · Effect: the statement fills one comment line, with a blank line before and after.

prose.rst
Check the demo pages
====================
#. Check that `the elements demo <http://localhost:8092/index.html>`_ loads.
#. Check that `the type echo page <http://localhost:8092/type-echo.html>`_ loads.

.. with a YAML body

Varies: statement body · Value: .. step checkLink: … · Effect: a one-key step reads as YAML, and the test uses a flow mapping.

prose.rst
Check the demo pages
====================
#. Check that `the elements demo <http://localhost:8092/index.html>`_ loads.
#. Check that `the type echo page <http://localhost:8092/type-echo.html>`_ loads.

.. across lines

Varies: statement layout · Value: an indented block below .. step · Effect: the indented lines belong to the comment, so the body can span lines.

prose.rst
Check the demo pages
====================
#. Check that `the elements demo <http://localhost:8092/index.html>`_ loads.
#. Check that `the type echo page <http://localhost:8092/type-echo.html>`_ loads.

Ways to write a statement in DITA

<?doc-detective ?> with a JSON body

Varies: statement form · Value: <?doc-detective step {…} ?> · Effect: a processing instruction named doc-detective holds the statement.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-pi-json">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

<?doc-detective ?> with a YAML body across lines

Varies: statement body · Value: a YAML body across lines in <?doc-detective test … ?> · Effect: each key sits on its own line, indented like the markup around it.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-pi-yaml-multiline">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

Indent the body to match the markup around it. Doc Detective removes the indentation that every line of the body shares, so the keys only need to line up with each other.

<?doc-detective ?> with attributes

Varies: statement body · Value: <?doc-detective step checkLink="…" ?> · Effect: each XML-style attribute becomes a field.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-pi-attributes">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

<!-- --> with attributes in DITA

Varies: statement form · Value: <!-- step checkLink="…" --> · Effect: an XML comment works the same as a processing instruction.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-html-comment-attributes">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

<data> with double quotes

Varies: statement form · Value: value="step checkLink='…'" · Effect: the attribute takes double quotes, so the values inside take single quotes.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-data-double-quotes">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

<data> with single quotes

Varies: statement form · Value: value='step {"checkLink": "…"}' · Effect: the attribute takes single quotes, so it can hold a JSON body.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-data-single-quotes">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
<li>Check that <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref> loads.</li>
</ol>
</body>
</topic>

testIgnore permutations

Each example has a bash code block that detection would turn into a runCode step. The detected variants show what keeps it from running.

testIgnore after a Markdown fence language

Varies: code fence meta · Value: ```bash testIgnore · Effect: detection skips the block.

prose.md
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
To fetch the page from a terminal instead, run:
```bash testIgnore
curl http://localhost:8092/index.html
```

testIgnore after an MDX fence language

Varies: code fence meta · Value: ```bash testIgnore · Effect: detection skips the block.

prose.mdx
# Check the demo pages
1. Check that [the elements demo](http://localhost:8092/index.html) loads.
To fetch the page from a terminal instead, run:
```bash testIgnore
curl http://localhost:8092/index.html
```

testIgnore in AsciiDoc source attributes

Varies: listing attributes · Value: [source,bash,testIgnore] · Effect: detection skips the listing.

prose.adoc
= Check the demo pages
. Check that http://localhost:8092/index.html[the elements demo] loads.
To fetch the page from a terminal instead, run:
[source,bash,testIgnore]
----
curl http://localhost:8092/index.html
----

:class: testIgnore on a reStructuredText code block

Varies: directive option · Value: :class: testIgnore · Effect: detection skips the code block.

prose.rst
Check the demo pages
====================
#. Check that `the elements demo <http://localhost:8092/index.html>`_ loads.
To fetch the page from a terminal instead, run:
.. code-block:: bash
:class: testIgnore
curl http://localhost:8092/index.html

An ignore block in HTML

Varies: code block marker · Value: an ignore block around the block · Effect: HTML has no testIgnore marker, so the ignore block keeps detection off the code.

prose.html
<!DOCTYPE html>
<html lang="en">
<head><title>Check the demo pages</title></head>
<body>
<h1>Check the demo pages</h1>
<ol>
<li>Check that <a href="http://localhost:8092/index.html">the elements demo</a> loads.</li>
</ol>
<p>To fetch the page from a terminal instead, run:</p>
<pre><code class="language-bash">curl http://localhost:8092/index.html</code></pre>
</body>
</html>

An ignore block in DITA

Varies: code block marker · Value: an ignore block around the <codeblock> · Effect: DITA has no testIgnore marker, so the ignore block keeps detection off the code.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="formats-dita-code-ignore-block">
<title>Check the demo pages</title>
<body>
<ol>
<li>Check that <xref href="http://localhost:8092/index.html" scope="external" format="html">the elements demo</xref> loads.</li>
</ol>
<p>To fetch the page from a terminal instead, run:</p>
<codeblock outputclass="language-bash">curl http://localhost:8092/index.html</codeblock>
</body>
</topic>