Skip to content

Docs: Implement version extraction from Cargo.toml and feature sync #56

@unclesp1d3r

Description

@unclesp1d3r

Implement version synchronization and template variables for existing documentation system

Issue Description

UPDATED SCOPE: The documentation infrastructure (mdBook + GitHub Actions) already exists and is fully functional. This issue focuses on implementing version synchronization between Cargo.toml and documentation, plus template variables for dynamic content injection.

Current State Analysis:

  • ✅ Complete mdBook setup with 7 plugins configured
  • ✅ GitHub Actions docs workflow deploying to GitHub Pages
  • ✅ Comprehensive justfile with docs commands (docs-build, docs-serve, docs-check)
  • ✅ 15+ documentation files covering installation, usage, security, development
  • ✅ Referenced spec files exist in .kiro/specs/documentation-setup/
  • Missing: Version extraction from Cargo.toml to docs
  • Missing: Template variables for dynamic version/feature content
  • Missing: CLI example validation against current clap configuration
  • 🚨 Critical: Version discrepancies exist across codebase (v0.2.6 in Cargo.toml, mixed references in docs)

Validation Steps

  1. Test current documentation build:

    just docs-build
    just docs-serve
  2. Verify version extraction (after implementation):

    # Test that documentation includes current Cargo.toml version
    cargo run --bin doc-version-sync
    grep "$(grep '^version' Cargo.toml | cut -d'"' -f2)" docs/book/index.html
  3. Validate CLI examples match current configuration:

    just docs-validate-cli

Expected Behavior

  • Documentation shows current Cargo.toml version automatically via template variables
  • Feature flags documented match current codebase exactly
  • CLI examples work with current clap configuration
  • Version-specific content updates automatically on build
  • All hardcoded version references replaced with dynamic templates

Proposed Implementation

1. Version Synchronization Script

Create src/bin/doc-version-sync.rs that:

  • Extracts version from Cargo.toml using regex parsing
  • Extracts feature flags from [features] section
  • Updates book.toml with template variables
  • Replaces hardcoded version references in markdown files
  • Validates CLI examples against current binary

2. Enhanced Template System

Add to docs/book.toml:

[preprocessor.variables]
[preprocessor.variables.variables]
version = "{{CARGO_VERSION}}"
features = ["json", "csv", "ssl", "additional_mysql_types", "verbose"]

3. Updated Justfile Commands

# Sync documentation with current codebase version
docs-sync:
    cargo run --bin doc-version-sync

# Enhanced docs-build with version sync
docs-build-sync: docs-sync docs-build

# Validate CLI examples against current code  
docs-validate-cli:
    cargo build --release
    # Test documented CLI examples work with current binary

4. GitHub Actions Integration

Update .github/workflows/docs.yml to include version sync step:

- name: Sync documentation version
  run: |
    cargo run --bin doc-version-sync
    git diff --exit-code || (echo "Documentation out of sync with version" && exit 1)

Acceptance Criteria

  1. ✅ WHEN documentation is generated THEN it SHALL include version information matching the current Cargo.toml version
  2. ✅ WHEN features are documented THEN feature flags SHALL be clearly indicated (e.g., "requires ssl feature")
  3. ✅ WHEN CLI options are documented THEN they SHALL match the current clap configuration
  4. ✅ WHEN examples are provided THEN they SHALL work with the current codebase and be testable
  5. ✅ WHEN breaking changes occur THEN migration guides SHALL be provided in the documentation

Remaining Tasks

  • Create src/bin/doc-version-sync.rs for version extraction
  • Add template variables to book.toml for dynamic content
  • Replace hardcoded version references in markdown files with templates
  • Create CLI example validation script
  • Add version sync to GitHub Actions workflow
  • Update justfile with docs-sync and docs-validate-cli commands
  • Resolve version discrepancies across codebase
  • Test version synchronization in all build environments

DoD (Definition of Done)

  • All Acceptance Criteria satisfied
  • Documentation shows correct version automatically via template variables
  • All CLI examples validated against current code
  • Feature flags accurately reflected via dynamic extraction
  • CI validates version synchronization on every build
  • No hardcoded version references remain in documentation
  • Version extraction works in all build environments (local, CI, GitHub Actions)
  • Version discrepancies resolved across Cargo.toml, CHANGELOG.md, and docs

Epic: #51 - Documentation Setup Epic


Note: This issue was significantly rescoped after analysis revealed the documentation infrastructure was already complete. Focus is now on the missing synchronization layer between codebase and documentation content.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions