Skip to content

feat: add get_project_metadata for QUARTO_EXECUTE_INFO - #19

Merged
mcanouil merged 4 commits into
mainfrom
feat/get-project-metadata
Oct 29, 2026
Merged

mcanouil merged 4 commits into
mainfrom
feat/get-project-metadata

Conversation

@mcanouil

Copy link
Copy Markdown
Owner

Several extensions read the QUARTO_EXECUTE_INFO file themselves to get the project's website and book metadata, each with its own error handling.
This adds get_project_metadata to metadata.lua, so they can share one tested reader.

It returns the format.metadata table.
When the variable is set but the file can't be used, it returns nil and one of 'file is unreadable', 'file is empty', 'invalid JSON' or 'no format.metadata table'.
When the variable is unset or empty, it returns nil alone, so single documents stay silent.
The module doesn't log or cache, and each extension decides whether to warn.

A decoder that returns nil counts as invalid JSON, so quarto-cli and q2 report the same reason.

get_project_repo_url now builds on it and takes an optional format_meta table, so an extension that already read the file doesn't read it again.
A side effect: JSON that isn't an object now gives nil instead of an error that stopped the filter.

The tests stub os.getenv and quarto.json and cover each failure path, website only, book only and both.

@mcanouil mcanouil added the Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses label Oct 29, 2026
@mcanouil mcanouil self-assigned this Oct 29, 2026
@mcanouil
mcanouil marked this pull request as ready for review October 29, 2026 14:48
@mcanouil
mcanouil merged commit 88cb64f into main Oct 29, 2026
2 checks passed
@mcanouil
mcanouil deleted the feat/get-project-metadata branch October 29, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant