adk-doc-audit
Documentation audit system for ADK-Rust that validates documentation against actual crate implementations.
Overview
The adk-doc-audit crate provides a comprehensive system for ensuring that ADK-Rust's documentation stays accurate and up-to-date with the actual crate implementations. It performs static analysis of documentation files, validates code examples, and cross-references API signatures with actual implementations.
Features
- API Reference Validation: Ensures all API references in documentation match actual implementations
- Code Example Compilation: Validates that code examples compile with current crate versions
- Version Consistency Checking: Verifies version references are current and consistent
- Cross-Reference Validation: Validates internal links and references
- Missing Feature Detection: Identifies features that exist in code but are missing from documentation
- Automated Suggestions: Provides fix suggestions for identified issues
- Comprehensive Reporting: Generates detailed audit reports in multiple formats (Console, JSON, Markdown)
- CI/CD Integration: Supports integration with build pipelines with appropriate exit codes
- Incremental Auditing: Process only changed files for efficient CI/CD workflows
Installation
Add to your Cargo.toml:
[]
= { = "https://github.com/zavora-ai/adk-rust" }
Or use the main ADK-Rust crate with the doc-audit feature:
[]
= { = "https://github.com/zavora-ai/adk-rust", = ["doc-audit"] }
Quick Start
Basic Usage
use ;
async
Single File Validation
use ;
use Path;
async
Incremental Audit
use ;
use PathBuf;
async
CLI Usage
The crate provides a command-line interface for easy integration with development workflows:
Full Audit
Run a complete audit of all documentation:
# Basic audit with console output
# Generate JSON report for programmatic consumption
# Generate Markdown report for documentation
Incremental Audit
Audit only specific files (useful for CI/CD when you know which files changed):
Single File Validation
Validate a specific documentation file:
Configuration File
Create a .adk-doc-audit.toml configuration file:
= "."
= "docs/official_docs"
= "console"
# Files to exclude from auditing
= [
"docs/internal/*",
"docs/drafts/*"
]
# Crates to exclude from analysis
= [
"example-crate",
"test-utils"
]
# Severity threshold for failing builds
= "warning"
= true
# Timeout for code example compilation
= "30s"
Then run without arguments:
Configuration
AuditConfig Builder
use ;
use Duration;
let config = builder
.workspace_path
.docs_path
.output_format
.excluded_files
.excluded_crates
.severity_threshold
.fail_on_critical
.example_timeout
.build;
Configuration Options
| Option | Description | Default |
|---|---|---|
workspace_path |
Path to the Rust workspace root | "." |
docs_path |
Path to documentation directory | "docs" |
output_format |
Report format (Console, Json, Markdown) | Console |
excluded_files |
Glob patterns for files to exclude | [] |
excluded_crates |
Crate names to exclude from analysis | [] |
severity_threshold |
Minimum severity to report | Info |
fail_on_critical |
Exit with error on critical issues | true |
example_timeout |
Timeout for compiling examples | 30s |
Issue Types and Severity
Issue Categories
- ApiMismatch: API references that don't match actual implementations
- VersionInconsistency: Version numbers that don't match workspace versions
- CompilationError: Code examples that fail to compile
- BrokenLink: Internal links that point to non-existent files
- MissingDocumentation: Public APIs not documented
- DeprecatedApi: References to deprecated APIs
Severity Levels
- Critical: Issues that make documentation incorrect or unusable
- Warning: Issues that may confuse users but don't break functionality
- Info: Minor issues or suggestions for improvement
CI/CD Integration
GitHub Actions
name: Documentation Audit
on:
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Run documentation audit
run: |
cargo install --git https://github.com/zavora-ai/adk-rust adk-doc-audit
adk-doc-audit audit --workspace . --docs docs --format json
Exit Codes
0: Audit passed (no critical issues)1: Audit failed (critical issues found or configuration error)
Incremental CI/CD
For faster CI/CD, audit only changed files:
# Get changed files from git
CHANGED_FILES=
if [; then
else
fi
Integration with ADK-Rust Workflows
Spec-Driven Development
The audit system integrates with ADK-Rust's spec-driven development workflow:
- Requirements Phase: Validate that all requirements are documented
- Design Phase: Ensure design documents reference valid APIs
- Implementation Phase: Verify code examples compile with new implementations
- Testing Phase: Validate that property tests are documented
Hook Integration
Set up automatic audits when crates are updated:
use ;
// Register hook for crate updates
let config = builder
.workspace_path
.docs_path
.build;
let orchestrator = new?;
// This would be called by the hook system when a crate is updated
orchestrator.register_hook;
Report Formats
Console Output
Human-readable output with colored indicators:
=== Documentation Audit Report ===
📊 Summary:
Total files: 15
Files with issues: 3
Total issues: 7
Critical: 2, Warning: 3, Info: 2
Coverage: 87.5%
❌ docs/api-reference.md:42
[Critical] API reference 'GeminiModel::new_with_config' not found in crate
💡 Suggestion: Use 'GeminiModel::with_config' instead
⚠️ docs/examples.md:15
[Warning] Version reference '0.1.8' doesn't match workspace version '0.2.0'
💡 Suggestion: Update to version '0.2.0'
JSON Output
Machine-readable format for integration:
Markdown Output
Documentation-friendly format:
Generated: 2024-01-15 10:30:00 UTC
- ----
**API reference 'GeminiModel::new_with_config' not found in crate**
- -
Advanced Usage
Custom Validators
Extend the audit system with custom validation logic:
use ;
use async_trait;
;
// Register custom validator
let mut orchestrator = new?;
orchestrator.add_validator;
Programmatic Report Processing
Process audit reports programmatically:
use ;
Troubleshooting
Common Issues
- "Workspace not found": Ensure the workspace path points to a directory with
Cargo.toml - "Documentation directory not found": Check that the docs path exists and contains markdown files
- "Compilation timeout": Increase
example_timeoutfor complex examples - "Permission denied": Ensure the process has read access to workspace and docs directories
Debug Mode
Enable debug logging for troubleshooting:
use tracing_subscriber;
// Initialize debug logging
fmt
.with_max_level
.init;
// Run audit with debug output
let report = orchestrator.run_full_audit.await?;
Performance Tuning
For large documentation sets:
let config = builder
.workspace_path
.docs_path
.example_timeout // Increase timeout
.excluded_files
.build;
Contributing
Contributions are welcome! Please see the ADK-Rust contributing guide for details.
Adding New Validators
To add new validation capabilities:
- Implement the
Validatortrait - Add configuration options if needed
- Write property tests for the validator
- Update documentation and examples
Extending Report Formats
To add new report formats:
- Implement the
ReportFormattertrait - Add the format to the
OutputFormatenum - Update CLI argument parsing
- Add tests and documentation
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.