HTML input format
HTML is the standard format for web pages. Doc Detective reads inline tests from HTML comments and detects steps from HTML tags.
File extensions
Doc Detective processes HTML files with the following extensions:
.html.htm
Inline test syntax
HTML files use HTML comments for inline tests:
Test start:
Step:
Test end:
Ignore blocks:
Example
Here’s a complete example of an HTML file with inline tests:
Detected tests
With step detection on, HTML files detect the steps listed in What gets detected, from HTML tags:
Statements, tags, and text inside <pre>, <code>, <script>, and <style> aren’t read. Prose is read as written in the source, so Type "kittens" doesn’t match the type pattern. Write the quotes as ".
For a generated site, point Doc Detective at your source files rather than the build output. Otherwise, every link and bold phrase on every page becomes a step. To change what’s detected, see Selectors and custom inputs.
JSON and YAML syntax
HTML inline tests support both JSON and YAML syntax:
JSON syntax:
YAML syntax:
Both formats work identically. Choose the format that’s most readable for your team.
Best practices
- Keep test comments on a single line
- Place test comments near the content they validate
- Use descriptive test IDs to identify tests in results
- Combine inline tests with detected tests so links, bold text, and code blocks become steps without extra comments
- Validate your HTML to ensure comments don’t break document structure
Integration with HTML toolchains
HTML test comments are standard HTML comments and don’t affect page rendering or functionality. This makes Doc Detective tests invisible to browsers and build tools while still being testable.
Common HTML documentation tools that work with Doc Detective:
- Static HTML sites: Any manually created HTML documentation
- Generated HTML: HTML output from documentation generators
- HTML help systems: CHM files and other HTML-based help formats
- Single-page applications: SPAs with HTML documentation sections
Working with templated HTML
If you use templating systems (like Handlebars, Jinja2, or EJS), you can include Doc Detective comments in your templates:
Handlebars example:
The test comments remain in the generated HTML and can be processed by Doc Detective.
Next steps
- Learn about inline tests for manual test definition
- See custom inputs to add detected test patterns for HTML
- Explore Markdown and DITA formats for detected test examples