X Tutup
Skip to content

fix: allow PDF/PNG generation when dont_generate_typst is True#577

Draft
majiayu000 wants to merge 4 commits intorendercv:mainfrom
majiayu000:fix/issue-550-typst-generation
Draft

fix: allow PDF/PNG generation when dont_generate_typst is True#577
majiayu000 wants to merge 4 commits intorendercv:mainfrom
majiayu000:fix/issue-550-typst-generation

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Fixed issue where setting dont_generate_typst: true would also disable PDF and PNG generation
  • Now uses a temporary file for typst compilation when the user doesn't want to save the .typ file

Changes

  • Modified generate_typst() to return a temp file path instead of None when dont_generate_typst=True
  • Updated generate_pdf() and generate_png() to always expect a valid typst path
  • Added regression tests to verify PDF/PNG generation works with dont_generate_typst=True
  • Updated existing test expectations to reflect the new behavior

Fixes #550

When dont_generate_typst was set to True, the entire PDF/PNG generation
was disabled because generate_typst returned None and generate_pdf/png
checked for None typst_path.

Now generate_typst creates a temporary file when dont_generate_typst=True,
allowing PDF/PNG compilation to proceed while not saving the .typ file
to the output directory.

Fixes rendercv#550
The function no longer returns None after the fix, so update the
return type from `pathlib.Path | None` to `pathlib.Path`.

Signed-off-by: majiayu000 <1835304752@qq.com>
@sinaatalay
Copy link
Member

Are we sure those temp dirs get removed at the end of the run?

When dont_generate_typst is True, generate_typst() creates a temporary
directory for the typst file. Previously, this temp directory was never
cleaned up, leading to leftover files in the system temp directory.

Changes:
- Modified generate_typst() to return a tuple (path, is_temporary) so
  callers know when cleanup is needed
- Added cleanup logic in run_rendercv() using a finally block to ensure
  temp directories are removed even if an error occurs
- Updated tests to verify the cleanup behavior

This addresses the review comment in PR rendercv#577 about temp directory cleanup.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@majiayu000
Copy link
Contributor Author

Good catch! You're absolutely right - the temp directories were not being cleaned up.

I've pushed a fix that:

  1. Modified generate_typst() to return a tuple (path, is_temporary) so the caller knows when cleanup is needed
  2. Added cleanup logic in run_rendercv() using a finally block to ensure temp directories are removed even if an error occurs during PDF/PNG generation
  3. Added tests to verify the cleanup behavior

The temp directory is now properly cleaned up after the PDF/PNG compilation is complete. All 444 tests pass.

Thanks for the review!

Move `import shutil` from inside test functions to the top of the file
to comply with ruff check rule PLC0415 (import should be at the top-level
of a file).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MRDGH2821
Copy link

OS's temp dir could also be used.
In case of windows, manual cleanup would be still required or the user needs to use Disk Cleaner to get it removed.

@sinaatalay sinaatalay force-pushed the main branch 3 times, most recently from cff31ca to 2b08030 Compare February 17, 2026 14:04
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.

[Bug] Disabling typst generation disables overall rendering

3 participants

X Tutup