Skip to content

Commit 3342a96

Browse files
committed
update/slicing_script
1 parent 14f9e3b commit 3342a96

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/scripts/slice_docs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ def build_hierarchy(flat_sections: List[MarkdownSection]) -> List[MarkdownSectio
127127
# 'property': 'properties',
128128
}
129129

130+
# Files that should ONLY be saved under specific parent directories
131+
# Key: filename (without .md), Value: list of allowed parent directories
132+
# If the file's path doesn't include one of these directories, it will be skipped
133+
FILES_ONLY_IN_DIRS = {
134+
'states': ['specs'],
135+
# Add more mappings here as needed, e.g.:
136+
# 'anatomy': ['specs'],
137+
}
138+
130139

131140
def normalize_title(title: str) -> str:
132141
"""
@@ -269,6 +278,15 @@ def save_slice(component_dir: Path, path_segments: List[str],
269278
"""
270279
dsm_dir = component_dir / 'dsm'
271280

281+
# Check if this file should only be saved in specific directories
282+
# e.g., 'states' should only be saved under 'specs/' directory
283+
if filename in FILES_ONLY_IN_DIRS:
284+
allowed_dirs = FILES_ONLY_IN_DIRS[filename]
285+
# Check if any of the path segments match an allowed directory
286+
if not any(seg in allowed_dirs for seg in path_segments):
287+
print(f" ⊘ Skipped: {filename}.md (not in allowed directories: {allowed_dirs})")
288+
return
289+
272290
# Build target directory (excluding last segment which is the filename)
273291
if len(path_segments) > 1:
274292
target_dir = dsm_dir / Path(*path_segments[:-1])

0 commit comments

Comments
 (0)