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}.
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.
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
Detected
Inline
Standalone
Markdown
MDX
Markdown
MDX
Markdown
MDX
JSON
YAML
- 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
.mdxpage uses{/* */}or[comment]: #statements. ```bash testIgnorekeeps thecurlblock from becoming arunCodestep. The ignore block keeps the link to the elements demo from becominggoToandcheckLinksteps.
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
Detected
Inline
Standalone
AsciiDoc
AsciiDoc
AsciiDoc
JSON
YAML
- 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 thecurllisting from becoming arunCodestep. 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
Detected
Inline
Standalone
HTML
HTML
HTML
JSON
YAML
- HTML reads statements only from
<!-- -->comments. - A
<code class="language-bash">block has notestIgnoremarker, so the ignore block keeps thecurlblock from becoming arunCodestep.
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
Detected
Inline
Standalone
reStructuredText
reStructuredText
reStructuredText
JSON
YAML
- 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: testIgnorekeeps thecurlblock from becoming arunCodestep. 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
Detected
Inline
Standalone
DITA
DITA
DITA
JSON
YAML
- A processing instruction starts with
<?doc-detective. - A
<data>element’snameisdoc-detective, and itsvalueholds 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 converttrue,false, and numbers. - A
<codeblock>has notestIgnoremarker, so the ignore block keeps thecurlblock from becoming arunCodestep.
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
Inline
Standalone
Markdown
Markdown
JSON
YAML
<!-- --> 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
Inline
Standalone
Markdown
Markdown
JSON
YAML
<!-- --> with attributes
Varies: statement body · Value: <!-- step checkLink="…" --> · Effect: each XML-style attribute becomes a field. false and numbers convert to their types.
Prose
Inline
Standalone
Markdown
Markdown
JSON
YAML
<!-- --> across lines
Varies: statement layout · Value: a comment that spans lines · Effect: the keyword and its body can sit on separate lines.
Prose
Inline
Standalone
Markdown
Markdown
JSON
YAML
[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
Inline
Standalone
Markdown
Markdown
JSON
YAML
[comment]: # ' '
Varies: statement form · Value: [comment]: # 'step {…}' · Effect: single quotes leave the JSON body’s double quotes free.
Prose
Inline
Standalone
Markdown
Markdown
JSON
YAML
[comment]: # " "
Varies: statement form · Value: [comment]: # "step checkLink: …" · Effect: double quotes can’t hold a JSON body, so the statements use YAML.
Prose
Inline
Standalone
Markdown
Markdown
JSON
YAML
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
Inline
Standalone
MDX
MDX
JSON
YAML
“ with a YAML body
Varies: statement body · Value: “ · Effect: a one-key step reads as YAML.
Prose
Inline
Standalone
MDX
MDX
JSON
YAML
“ across lines
Varies: statement layout · Value: a JSX comment that spans lines · Effect: the keyword and its body can sit on separate lines.
Prose
Inline
Standalone
MDX
MDX
JSON
YAML
[comment]: # ' ' in an MDX file
Varies: statement form · Value: [comment]: # 'step {…}' · Effect: works in MDX too, where HTML comments break the build.
Prose
Inline
Standalone
MDX
MDX
JSON
YAML
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
Inline
Standalone
AsciiDoc
AsciiDoc
JSON
YAML
// ( ) 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
Inline
Standalone
AsciiDoc
AsciiDoc
JSON
YAML
//// block across lines
Varies: statement form · Value: a //// comment block · Effect: the whole block is the statement, so a step can span lines.
Prose
Inline
Standalone
AsciiDoc
AsciiDoc
JSON
YAML
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
Inline
Standalone
HTML
HTML
JSON
YAML
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
Inline
Standalone
HTML
HTML
JSON
YAML
<!-- --> with attributes in HTML
Varies: statement body · Value: <!-- step checkLink="…" --> · Effect: each XML-style attribute becomes a field.
Prose
Inline
Standalone
HTML
HTML
JSON
YAML
<!-- --> 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
Inline
Standalone
HTML
HTML
JSON
YAML
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
Inline
Standalone
reStructuredText
reStructuredText
JSON
YAML
.. 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
Inline
Standalone
reStructuredText
reStructuredText
JSON
YAML
.. 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
Inline
Standalone
reStructuredText
reStructuredText
JSON
YAML
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
Inline
Standalone
DITA
DITA
JSON
YAML
<?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
Inline
Standalone
DITA
DITA
JSON
YAML
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
Inline
Standalone
DITA
DITA
JSON
YAML
<!-- --> with attributes in DITA
Varies: statement form · Value: <!-- step checkLink="…" --> · Effect: an XML comment works the same as a processing instruction.
Prose
Inline
Standalone
DITA
DITA
JSON
YAML
<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
Inline
Standalone
DITA
DITA
JSON
YAML
<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
Inline
Standalone
DITA
DITA
JSON
YAML
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
Detected
Inline
Standalone
Markdown
Markdown
Markdown
JSON
YAML
testIgnore after an MDX fence language
Varies: code fence meta · Value: ```bash testIgnore · Effect: detection skips the block.
Prose
Detected
Inline
Standalone
MDX
MDX
MDX
JSON
YAML
testIgnore in AsciiDoc source attributes
Varies: listing attributes · Value: [source,bash,testIgnore] · Effect: detection skips the listing.
Prose
Detected
Inline
Standalone
AsciiDoc
AsciiDoc
AsciiDoc
JSON
YAML
:class: testIgnore on a reStructuredText code block
Varies: directive option · Value: :class: testIgnore · Effect: detection skips the code block.
Prose
Detected
Inline
Standalone
reStructuredText
reStructuredText
reStructuredText
JSON
YAML
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
Detected
Inline
Standalone
HTML
HTML
HTML
JSON
YAML
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.