Skip to navigation

AsciiDoc input format

AsciiDoc is a lightweight markup language popular in technical documentation. Doc Detective reads inline tests from AsciiDoc comments and detects steps from AsciiDoc syntax.

File extensions

Doc Detective processes AsciiDoc files with the following extensions:

  • .adoc
  • .asciidoc
  • .asc

Inline test syntax

AsciiDoc files use line comments for inline tests:

// (test { "testId": "my-test" })
// (step { "goTo": "https://example.com" })
// (test end)

The comment syntax uses parentheses to distinguish test comments from regular AsciiDoc comments.

Test start:

// (test { "testId": "my-test" })

Step:

// (step { "goTo": "https://example.com" })

Test end:

// (test end)

Ignore blocks:

// (test ignore start)
Content to ignore
// (test ignore end)

Example

Here’s a complete example of an AsciiDoc file with inline tests:

// (test { "testId": "doc-test" })
== Getting Started
Navigate to the application:
// (step { "goTo": "https://app.example.com" })
Click the *Start* button:
// (step { "click": "Start" })
Enter your username:
// (step { "type": { "keys": "testuser", "selector": "[name=username]" } })
Submit the form:
// (step { "click": "Submit" })
// (test end)

Detected tests

With step detection on, AsciiDoc files detect the steps listed in What gets detected, from AsciiDoc syntax:

StepAsciiDoc that matches
goToGo to https://example.com[the site] or Go to link:https://example.com[the site], and the other navigation verbs
checkLinkAny https://...[text] or link:https://...[text] link
clickClick *Search* or Click **Search**, and the other click verbs
findAny *bold* or **bold** text
screenshotimage::results.png[Results, role=screenshot], or an image under a [.screenshot] line
typeType "kittens" in prose
httpRequestA [source,http] listing, or a listing with no language, that holds a request
runCodeA [source,bash] listing, or one in python, py, javascript, or js, unless testIgnore follows the language, as in [source,bash,testIgnore]. These steps are unsafe

Comments, links, and formatting inside listings, literal blocks, and passthrough blocks aren’t read, and neither are indented literal paragraphs. A // comment counts only at the start of a line. To change what’s detected, see Selectors and custom inputs.

JSON and YAML syntax

AsciiDoc inline tests support both JSON and YAML syntax:

JSON syntax:

// (test { "testId": "my-test", "description": "Test description" })
// (step { "goTo": "https://example.com" })

YAML syntax:

// (test testId: my-test description: Test description)
// (step goTo: https://example.com)

Both formats work identically. Choose the format that’s most readable for your team.

Best practices

  • Use parentheses in comments to distinguish test statements from regular comments
  • Keep test comments on a single line
  • Use descriptive test IDs to identify tests in results
  • Combine inline tests with detected tests so links, bold text, and listings become steps without extra comments
  • Use YAML syntax for simpler, more readable inline tests

Integration with AsciiDoc toolchains

AsciiDoc test comments are standard AsciiDoc comments and don’t affect document rendering. This makes Doc Detective tests invisible to your documentation build process while still being testable.

Common AsciiDoc toolchains that work with Doc Detective:

  • Asciidoctor: The most popular AsciiDoc processor
  • Antora: Site generator for AsciiDoc documentation
  • Jekyll AsciiDoc: AsciiDoc plugin for Jekyll
  • Hugo: Static site generator with AsciiDoc support

Next steps