## ----setup, include = FALSE--------------------------------------------------- # This vignette runs against recorded, credential-free API fixtures. A maintainer # records them once with real Azure image credentials # (data-raw/record-doc-outputs.R) and commits them under vignettes/media-generation/. # When the fixtures are present the image call below executes and its real result # -- including the generated picture -- is shown. When they are absent the API # chunk is not evaluated so the vignette still builds without credentials. Nothing # on this page is fabricated: illustrative-only calls are marked eval = FALSE and # show code without invented output. fixture_dir <- "media-generation" recording <- nzchar(Sys.getenv("FOUNDRY_RECORD_DOCS")) have_fixtures <- dir.exists(fixture_dir) && length(list.files(fixture_dir)) > 0 run_api <- requireNamespace("httptest2", quietly = TRUE) && (recording || have_fixtures) # Attach foundryR before start_vignette(): httptest2 only sources the package's # inst/httptest2/start-vignette.R (which sets replay placeholders) from attached # packages. library(foundryR) if (run_api) { httptest2::start_vignette(fixture_dir) } knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = run_api ) # Embed the generated image inline as a base64 data URI, reading the file that # foundry_save_image() just wrote. This demonstrates that helper and renders the # real picture reliably offline, with no external-file handling (mirrors the #