HTML input format
HTML is the standard format for web pages. Doc Detective supports inline tests in HTML files using HTML comment syntax.
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
HTML currently only supports inline test statements. Detected test patterns (automatic test generation from content) are not included in the default configuration.
To add detected test functionality to HTML files, you can define custom markup patterns in your configuration. See custom inputs for examples.
Example custom patterns for HTML:
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
- Consider using custom markup patterns for automatic test detection
- 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