Skip to content

Commit 23491a8

Browse files
committed
fix(extract): apply stub-depth to templated files too
Files deeper than stub_depth were only dropped when they had 0 template replacements. Deep files with incidental replacements (e.g. a project name appearing in a nested reference doc) were still kept as .die templates. Now the depth check applies regardless of replacement count.
1 parent 5657b71 commit 23491a8

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

src/extract/mod.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,23 @@ pub fn plan_extraction(options: &ExtractOptions) -> Result<ExtractionPlan> {
314314
let (replaced, count) = apply_replacements(content, &rules);
315315

316316
if count > 0 {
317-
// Has template replacements — keep content, add .die suffix
318-
let mut p = template_path.as_os_str().to_string_lossy().to_string();
319-
p.push_str(DEFAULT_TEMPLATES_SUFFIX);
320-
planned_files.push(PlannedExtractFile {
321-
template_path: PathBuf::from(p),
322-
content: ExtractedContent::Text {
323-
content: replaced,
324-
replacement_count: count,
325-
},
326-
stubbed: false,
327-
});
317+
// Has template replacements — but still drop if too deep
318+
let depth = file.relative_path.components().count();
319+
if depth > options.stub_depth {
320+
dropped_count += 1;
321+
dropped_paths.push(file.relative_path.clone());
322+
} else {
323+
let mut p = template_path.as_os_str().to_string_lossy().to_string();
324+
p.push_str(DEFAULT_TEMPLATES_SUFFIX);
325+
planned_files.push(PlannedExtractFile {
326+
template_path: PathBuf::from(p),
327+
content: ExtractedContent::Text {
328+
content: replaced,
329+
replacement_count: count,
330+
},
331+
stubbed: false,
332+
});
333+
}
328334
} else {
329335
// No replacements — classify as boilerplate, content, or dropped
330336
match classify_file(&file.relative_path, options.stub_depth) {

0 commit comments

Comments
 (0)