Skip to content

feat: add RecipeEntry::related_files() for discovering associated files#6

Merged
dubadub merged 7 commits intomainfrom
feat/related-files
Feb 18, 2026
Merged

feat: add RecipeEntry::related_files() for discovering associated files#6
dubadub merged 7 commits intomainfrom
feat/related-files

Conversation

@dubadub
Copy link
Member

@dubadub dubadub commented Feb 17, 2026

Summary

  • Add RecipeEntry::related_files() method that returns all filesystem paths related to a recipe
  • Collects title images, step/section images, and recursively referenced recipe files
  • Detects recipe references via regex (@./path and @../path patterns in Cooklang content)
  • Handles cycles, deduplicates paths, and silently skips missing references
  • Exposes the method via FFI (FfiRecipeEntry::related_files() -> Vec<String>) for iOS/Android

Test plan

  • 7 unit tests for extract_recipe_references (simple, multiple, no refs, no quantity, dedup, parent dir, trailing punctuation)
  • 8 tests for related_files (empty, title image, step images, content-based, referenced recipe, recursive chain, circular reference, missing reference)
  • 1 FFI integration test
  • All 76 tests pass, clippy clean, fmt clean, release build succeeds

… support

Add related_files() method that collects all files associated with a recipe:
- Title and step images
- Referenced .cook files detected via @./path and @../path syntax
- Recursively collects related files from referenced recipes
- Cycle detection prevents infinite loops in circular references

Update extract_recipe_references regex to also match ../ relative paths.
Canonicalize paths in collect_related_files to prevent cycle detection
failures with ../path references. Cache regex compilation with OnceLock
to avoid recompilation on every call. Exclude trailing punctuation from
regex captures. Clean up HashSet imports and add tests for parent-dir
references and trailing punctuation stripping.
@dubadub dubadub merged commit 3d42b68 into main Feb 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant