Skip to content

Improve pre/post render script logging#12444

Merged
cderv merged 12 commits into
mainfrom
post-render/logging
Feb 23, 2026
Merged

Improve pre/post render script logging#12444
cderv merged 12 commits into
mainfrom
post-render/logging

Conversation

@cderv

@cderv cderv commented Apr 3, 2025

Copy link
Copy Markdown
Member

This is an idea coming from work on quarto-dev/quarto-web#1612

Logging improvement

The logging was not completely explicit as it was showing only the script name without context. This PR adds a Running script prefix:

Running script 'myscript.ts'

New environment variables

Two new environment variables are set for pre/post render scripts so they can adapt their output:

  • QUARTO_PROJECT_SCRIPT_PROGRESS"1" when progress can be shown, "0" otherwise
  • QUARTO_PROJECT_SCRIPT_QUIET"1" when --quiet flag is active, "0" otherwise

progress is true when rendering multiple files or when explicitly requested via options.

Refactoring

The handler/non-handler code paths in runScripts were consolidated using a default handler with nullish coalescing (??), eliminating duplicated logic. Environment initialization was also moved before the loop, fixing a pre-existing issue where the non-handler branch didn't copy the caller's env.

@cderv cderv force-pushed the post-render/logging branch 2 times, most recently from d5dc015 to c5a2169 Compare April 3, 2025 17:27
@cscheid cscheid modified the milestones: v1.7, v1.8 Apr 7, 2025
@cscheid

cscheid commented Apr 8, 2025

Copy link
Copy Markdown
Member

@cderv I'm pushing this to v1.8 but feel free to move back to v1.7 if you've made the changes we talked about last week.

@cderv cderv force-pushed the post-render/logging branch from c5a2169 to 45c8580 Compare April 8, 2025 18:55
@cderv

cderv commented Apr 8, 2025

Copy link
Copy Markdown
Member Author

I rebased - this is where I was.

@cscheid

cscheid commented Apr 8, 2025

Copy link
Copy Markdown
Member

Right - we had talked about using QUARTO_QUIET and QUARTO_PROGRESS instead, and making that part of the codebase less branchy. I think that would be a worthy change (and doesn't need to happen for 1.7).

@cderv

cderv commented Apr 9, 2025

Copy link
Copy Markdown
Member Author

QUARTO_QUIET and QUARTO_PROGRESS instead

Yeah I used more verbose env var name because I feel those two are too generic... We are in pre-render post-render script context here, so I wanted to scope the variable name as it is for QUARTO_PROJECT_OUTPUT_DIR

It does not apply to quarto run for example. So it seems there topic here is to make env var available in a clever way, wherever they are supposed to (e.g quarto run, pre-render, post-render, execution ? Lua filters ?)

A border topic.

making that part of the codebase less branchy.

I have done that part by removing the if else and using a default handler.run. Did you have in mind something more generic like making quarto run and pre/post render sharing even more logic ?

Let's continue in 1.8 then.

@cderv cderv self-assigned this Apr 9, 2025
@cderv cderv added the early-in-release An issue that should be worked on early in the release (likely due to risk) label Apr 9, 2025
@cderv cderv force-pushed the post-render/logging branch from 45c8580 to df892dd Compare May 6, 2025 13:43
@posit-snyk-bot

posit-snyk-bot commented May 6, 2025

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv cderv force-pushed the post-render/logging branch 2 times, most recently from d5ef878 to b884232 Compare June 18, 2025 15:20
@cderv cderv modified the milestones: v1.8, v1.9 Sep 18, 2025
@cscheid cscheid modified the milestones: v1.9, v1.10 Feb 17, 2026
@cderv cderv force-pushed the post-render/logging branch 2 times, most recently from 79b6a54 to 3335dc3 Compare February 19, 2026 17:41
cderv and others added 4 commits February 21, 2026 11:24
…_QUIET env vars

Pre/post render scripts now receive these env vars but had no test coverage.
The new test fixture uses a pre-render script to dump the env var values to
a JSON file, then verifies the values match expectations (progress=1 for
multi-file projects, quiet=0 without --quiet flag).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eardowns

Both tests render website projects but only cleaned up their specific
side-effect files, leaving _site/ directories behind after each run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The llm-docs documented validJsonWithFields with fields: string[] but
the actual signature takes Record<string, unknown>. Also adds missing
trailing newline to project-prepost.test.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cderv cderv force-pushed the post-render/logging branch from 3335dc3 to d59c890 Compare February 21, 2026 10:33
cderv added a commit to quarto-dev/quarto-web that referenced this pull request Feb 23, 2026
…ET env vars

Add two new environment variables from quarto-dev/quarto-cli#12444 to the
pre/post render scripts documentation and the environment variables reference.
These let scripts adapt their output based on progress display availability
and quiet mode.
@cderv cderv merged commit 98be8a6 into main Feb 23, 2026
51 checks passed
@cderv cderv deleted the post-render/logging branch February 23, 2026 09:44
cderv added a commit to quarto-dev/quarto-web that referenced this pull request Feb 23, 2026
…PT_QUIET env vars (#1894)

* Document QUARTO_PROJECT_SCRIPT_PROGRESS and QUARTO_PROJECT_SCRIPT_QUIET env vars

Add two new environment variables from quarto-dev/quarto-cli#12444 to the
pre/post render scripts documentation and the environment variables reference.
These let scripts adapt their output based on progress display availability
and quiet mode.

* Fix markdown tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

early-in-release An issue that should be worked on early in the release (likely due to risk)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants