Skip to content

Commit a580d8d

Browse files
committed
fix: Fix documentation setup bugs in init script
- Fix os.makedirs error when output_path has no parent directory - Fix docs_choice variable scope issue by using docs_enabled flag - Clarify example code prompt to show (1/2/3) for clearer default indication These fixes address issues discovered during UX testing of the documentation setup flow.
1 parent 895b8e2 commit a580d8d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/init_project.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ def template_file(template_path: str, output_path: str, replacements: dict) -> N
6666
for placeholder, value in replacements.items():
6767
content = content.replace(f"{{{placeholder}}}", value)
6868

69-
# Ensure parent directory exists
70-
os.makedirs(os.path.dirname(output_path), exist_ok=True)
69+
# Ensure parent directory exists (only if there is a parent directory)
70+
parent_dir = os.path.dirname(output_path)
71+
if parent_dir:
72+
os.makedirs(parent_dir, exist_ok=True)
7173

7274
with open(output_path, "w") as f:
7375
f.write(content)
@@ -165,7 +167,7 @@ def main() -> None:
165167
"1. Keep example code (useful for reference)\n"
166168
"2. Create minimal placeholder test (ensures checks pass)\n"
167169
"3. Remove all example code (clean slate)\n"
168-
"Choose option", "1"
170+
"Choose option (1/2/3)", "1"
169171
)
170172

171173
# Create module directory with project name (replacing src)
@@ -272,7 +274,8 @@ def test_add():
272274
"\nSet up documentation? (Y/n)", "y"
273275
)
274276

275-
if docs_choice.lower() in ('y', 'yes', ''):
277+
docs_enabled = docs_choice.lower() in ('y', 'yes', '')
278+
if docs_enabled:
276279
# Extract GitHub username from git config or use placeholder
277280
try:
278281
github_url = subprocess.check_output(["git", "config", "remote.origin.url"], text=True).strip()
@@ -364,7 +367,7 @@ def test_add():
364367
"4. Run 'make check' to verify everything works"
365368
]
366369

367-
if docs_choice.lower() in ('y', 'yes', ''):
370+
if docs_enabled:
368371
next_steps.extend([
369372
"5. Serve documentation locally: 'make docs-serve'",
370373
"6. Update docs content in docs/ directory",

0 commit comments

Comments
 (0)