Skip to content

docs: document conditional execution via QUARTO_EXECUTE_INFO#2043

Merged
cderv merged 18 commits into
mainfrom
docs/13514-conditional-execution
Jun 10, 2026
Merged

docs: document conditional execution via QUARTO_EXECUTE_INFO#2043
cderv merged 18 commits into
mainfrom
docs/13514-conditional-execution

Conversation

@cderv

@cderv cderv commented May 26, 2026

Copy link
Copy Markdown
Member

Cross-link the existing QUARTO_EXECUTE_INFO reference page (docs/advanced/quarto-execute-info.qmd) from the six pages users actually browse when looking for conditional-execution behavior. The reference page itself is not modified.

Per the issue thread on quarto-dev/quarto-cli#13514, users want both:

  • a single canonical place documenting the env var (docs/advanced/quarto-execute-info.qmd, already exists)
  • concise, language-specific examples on the pages users land on (R, Python, Julia)

This branch addresses the second part — the first already exists.

Changes

  • docs/computations/execution-options.qmd — new ## Conditional Execution section explaining the distinction from format-based conditional content.
  • docs/computations/r.qmd, python.qmd, julia.qmd## Conditional Execution section per language, with a short verbatim snippet showing how to read QUARTO_EXECUTE_INFO. The R section also points at knitr::is_html_output(), knitr::is_latex_output(), and knitr::pandoc_to() for users who only need the common cases.
  • docs/authoring/conditional.qmd — explicit clarifier that .content-visible / .content-hidden hide output but do not skip execution (per cwickham's ask in the thread).
  • docs/authoring/cross-references-divs.qmd — same execution clarifier, plus a note pointing at project profiles as another axis for content variation beyond when-format.
  • docs/authoring/_visibility-vs-execution.md — shared partial used by both authoring pages so the execution-vs-visibility note has a single source of truth.

The added language snippets contain no executable code (wrapped in verbatim markdown fences with {{lang}} escaped cell markers), so no _freeze/ updates are introduced.

Test Plan

  • Render each modified page; confirm new sections appear in the page TOC and link targets resolve.
  • Confirm cross-references-divs.qmd Conditional Content section now ends with the two notes (execution + project profiles) plus the existing example.
  • Confirm _visibility-vs-execution.md partial renders identically in both consumer pages.
  • No _freeze/ regeneration triggered.

Closes quarto-dev/quarto-cli#13514

@cderv cderv requested a review from cwickham May 26, 2026 15:17
@github-actions github-actions Bot temporarily deployed to pull request May 26, 2026 15:25 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

@cwickham cwickham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edits look great!

Is this comment in the PR from Claude?:

The added language snippets contain no executable code (wrapped in verbatim markdown fences with {{lang}} escaped cell markers), so no _freeze/ updates are introduced.

The reasoning seems wrong, i.e. even if includes don't introduce executable code, we still need to update _freeze/ if the original page has executable code. Might be worth a rule/instruction somewhere for Claude...

In this case docs/computations/execution-options.qmd has executable code and does need a re-render, commit to _freeze/.

Comment thread docs/computations/julia.qmd
Comment thread docs/computations/julia.qmd Outdated
Comment thread docs/authoring/cross-references-divs.qmd Outdated
Comment thread docs/computations/execution-options.qmd
@github-actions github-actions Bot temporarily deployed to pull request June 10, 2026 09:06 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

@cderv

cderv commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Yes, that comment was from Claude — and the reasoning was wrong. I should have catch it. Thank you !

To avoid this in the future, I added two enforcement layers to the branch:

  • .githooks/pre-commit — blocks commits where a staged .qmd with a _freeze/ entry has a stale hash. Activate with git config core.hooksPath .githooks.
  • .claude/settings.json — a Claude Code PreToolUse hook that intercepts git commit and git push in Claude sessions and runs the same check.

Both delegate to:

https://github.com/quarto-dev/quarto-web/blob/09e75b8fc1b221d9b53f503a7dca59b67b5831bc/.githooks/check-freeze.sh

The rule in .claude/rules/quarto-web-workflow.md was also updated — quarto render <file.qmd> is now the prescribed fix when the hook fires.

Hopefully this works on Mac too, and will help us and claude to know when to update.

I wish to have a 'quarto inspect ' output that tell us if the document is frozen. We could then always re-render.

@github-actions github-actions Bot temporarily deployed to pull request June 10, 2026 10:10 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot temporarily deployed to pull request June 10, 2026 10:26 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

cderv and others added 18 commits June 10, 2026 12:35
Adds a section linking to docs/advanced/quarto-execute-info.qmd
so users browsing execution options discover the format-aware
QUARTO_EXECUTE_INFO env var.

Part of #13514.
Points readers of computations/r.qmd at QUARTO_EXECUTE_INFO so
they can branch on output format. Mirrors the additions for
Python and Julia.

Part of #13514.
The {r} marker was unescaped inside a markdown verbatim block;
Quarto would have treated it as an executable cell on render.
Matches the {{r}} escape pattern used by the sibling Chunk Labels
example in the same file.

Part of #13514.
Points readers of computations/python.qmd at QUARTO_EXECUTE_INFO
so they can branch on output format. Mirrors the additions for
R and Julia.

Part of #13514.
Points readers of computations/julia.qmd at QUARTO_EXECUTE_INFO
so they can branch on output format. Mirrors the additions for
R and Python.

Part of #13514.
Markup-based .content-visible / .content-hidden hide output but
do not skip execution. Adds a pointer section to
QUARTO_EXECUTE_INFO for the execution-level case.

Part of #13514.
Pre-existing EOF lacked a terminal newline; appending Conditional
Execution section preserved that. Aligns with other .qmd files in
the repo.

Part of #13514.
The conditional-content example in cross-references-divs.qmd
hides one branch but still runs both. Adds two pointers:
(1) QUARTO_EXECUTE_INFO for users who need to skip execution,
(2) project profiles as another axis for content variation
beyond output format. Both flagged in issue thread.

Part of #13514.
conditional.qmd and cross-references-divs.qmd both clarify that
.content-visible / .content-hidden hide output but do not skip
execution. The two paragraphs duplicated the same takeaway in
slightly different words. Extract the single canonical version
to docs/authoring/_visibility-vs-execution.md and include it
from both pages. The project-profiles paragraph in
cross-references-divs.qmd stays inline (specific to that page).

Part of #13514.
R cells run through knitr by default, which has long offered
is_html_output(), is_latex_output(), and pandoc_to() for the
common format-detection cases. Worth pointing readers at those
alongside the engine-agnostic QUARTO_EXECUTE_INFO approach
(flagged in the issue thread by cderv).

Part of #13514.
Co-authored-by: Charlotte Wickham <charlotte.wickham@posit.co>
- Add 'For example' sentence to all language Conditional Execution
  sections, making the HTML-format example explicit
- Repeat Conditional Execution section in the jupyter engine section
  of julia.qmd (it applied to both engines but was only under julia)
- Reword the when-meta/profiles paragraph in cross-references-divs.qmd
  to lead with the user intent rather than the mechanism
- Update _freeze/ hash and markdown for execution-options.qmd whose
  cached source hash was stale after the prior commit added the section
Documents when freeze updates are needed (any source change to a page
with executable code), the correct hash computation method, and a manual
update procedure for when quarto render cannot run in the local env.

# Conflicts:
#	.claude/rules/quarto-web-workflow.md
.githooks/check-freeze.sh: core logic verifying that any .qmd file with
a _freeze/ entry has a current hash (MD5 of LF-normalized source). Supports
commit mode (staged files) and push mode (commits ahead of upstream).

.githooks/pre-commit: git pre-commit hook calling the check; activate with
  git config core.hooksPath .githooks

.githooks/claude-hook.sh: Claude Code PreToolUse wrapper reading the Bash
tool input JSON from stdin and routing to check-freeze.sh.

.claude/settings.json: registers the hook for Bash tool calls, blocking
git commit and git push when a stale freeze is detected.
- Replace mapfile (bash 4+ only) with <<< heredoc, compatible with
  bash 3.2 (macOS system bash)
- Add md5_lf() wrapper: uses md5sum (Linux/Windows) or md5 -r (macOS)
- Redirect blocking message to stderr so Claude Code PreToolUse hook
  surfaces it correctly (tested on Windows Git Bash)
- Set all three .githooks/ scripts to 100755 so git runs them on
  Unix/macOS (non-executable hooks are silently ignored there)
- Read freeze JSON from git objects (staged index or HEAD) instead of
  working tree, avoiding false passes when the freeze file is updated
  on disk but not yet staged alongside the .qmd change
- Update _freeze/ check command in rule to `git diff HEAD -- _freeze/`
  so it shows both staged and unstaged changes (vs --stat which showed
  only unstaged, hiding already-staged freeze updates)
@cderv cderv force-pushed the docs/13514-conditional-execution branch from fddfa9c to c2b0f90 Compare June 10, 2026 11:56
@github-actions github-actions Bot temporarily deployed to pull request June 10, 2026 12:03 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

@cderv cderv merged commit b90194c into main Jun 10, 2026
4 checks passed
@cderv cderv deleted the docs/13514-conditional-execution branch June 10, 2026 12:40
@github-actions

Copy link
Copy Markdown
Contributor

Successfully created backport PR for prerelease:

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.

Document engine-agnostic approach to conditional execution

2 participants