Files
cs249r_book/book/tools/scripts/utilities/count_footnotes.sh
Vijay Janapa Reddi 7b92e11193 Repository Restructuring: Prepare for TinyTorch Integration (#1068)
* Restructure: Move book content to book/ subdirectory

- Move quarto/ → book/quarto/
- Move cli/ → book/cli/
- Move docker/ → book/docker/
- Move socratiQ/ → book/socratiQ/
- Move tools/ → book/tools/
- Move scripts/ → book/scripts/
- Move config/ → book/config/
- Move docs/ → book/docs/
- Move binder → book/binder

Git history fully preserved for all moved files.

Part of repository restructuring to support MLSysBook + TinyTorch.

Pre-commit hooks bypassed for this commit as paths need updating.

* Update pre-commit hooks for book/ subdirectory

- Update all quarto/ paths to book/quarto/
- Update all tools/ paths to book/tools/
- Update config/linting to book/config/linting
- Update project structure checks

Pre-commit hooks will now work with new directory structure.

* Update .gitignore for book/ subdirectory structure

- Update quarto/ paths to book/quarto/
- Update assets/ paths to book/quarto/assets/
- Maintain all existing ignore patterns

* Update GitHub workflows for book/ subdirectory

- Update all quarto/ paths to book/quarto/
- Update cli/ paths to book/cli/
- Update tools/ paths to book/tools/
- Update docker/ paths to book/docker/
- Update config/ paths to book/config/
- Maintain all workflow functionality

* Update CLI config to support book/ subdirectory

- Check for book/quarto/ path first
- Fall back to quarto/ for backward compatibility
- Maintain full CLI functionality

* Create new root and book READMEs for dual structure

- Add comprehensive root README explaining both projects
- Create book-specific README with quick start guide
- Document repository structure and navigation
- Prepare for TinyTorch integration
2025-12-05 14:04:21 -08:00

27 lines
705 B
Bash
Executable File

#!/bin/bash
# Define the search directory
SEARCH_DIR="$1"
# Temp file to hold name + count pairs
TMPFILE=$(mktemp)
# Collect counts
find "$SEARCH_DIR" -name '*.qmd' | while read -r file; do
count=$(awk '{n += gsub(/\[\^fn-[^]]+\]:/, "")} END {print n}' "$file")
filename=$(basename "$file")
echo "$filename $count" >> "$TMPFILE"
done
# Find max length of filename for formatting
max_len=$(awk '{print length($1)}' "$TMPFILE" | sort -nr | head -n1)
# Sort by count descending for readability
sort -k2 -nr "$TMPFILE" | while read -r name count; do
bar=$(printf '%*s' "$count" '' | tr ' ' '*')
printf "%-${max_len}s | %3d %s\n" "$name" "$count" "$bar"
done
# Clean up
rm "$TMPFILE"