pdftract/measure_doc_coverage.sh
jedarden 1c6f26ecaa fix(bf-4mkhv): clean up unused imports in hash.rs
The bead description mentioned compile errors in hash.rs from API drift,
but those errors were either already fixed or misattributed. The API usage
was already correct:
- compute_fingerprint already takes 3 arguments with source
- len() already propagates Result with ?
- read_at method already used correctly
- Catalog fields accessed via trailer correctly

Only cleanup: removed unused std::fs::File and std::io imports.

Verification: notes/bf-4mkhv.md
2026-06-01 09:43:48 -04:00

32 lines
1 KiB
Bash

#!/usr/bin/env bash
# Measure documentation example coverage for pdftract-core
cd /home/coding/pdftract/crates/pdftract-core
# Count public items and those with examples
total_items=0
items_with_examples=0
# Find all .rs files in src/
find src -name "*.rs" -type f | while read -r file; do
# Extract public items (pub fn, pub struct, pub enum, pub trait, pub type, pub mod)
# and check if they have doc comments with examples
# We'll use a simple grep-based approach to find pub items
# and check preceding lines for ```rust examples
grep -n "^pub " "$file" | while IFS=: read -r line_num _; do
((total_items++))
# Look back up to 50 lines for ```rust example
if sed -n "$((line_num - 50)),${line_num}p" "$file" | grep -q '```rust'; then
((items_with_examples++))
fi
done
done
echo "Total items with examples: $items_with_examples / $total_items"
if [ "$total_items" -gt 0 ]; then
coverage=$(echo "scale=1; 100 * $items_with_examples / $total_items" | bc)
echo "Coverage: $coverage%"
fi