-
Notifications
You must be signed in to change notification settings - Fork 1k
Replace prerelease-link-subdomain with version-aware shortcode #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
14b9f53
Replace prerelease-link-subdomain with version-aware shortcode
cderv 6bc8b7f
Use version comparison (<=) instead of equality check
cderv 9a4c7aa
Update PDF accessibility blog post to use prerelease-docs-url shortcode
cderv 25b325f
Add error handling to prerelease-docs-url shortcode
cderv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| title: Prerelease Docs URL | ||
| author: Quarto | ||
| version: 0.0.1 | ||
| contributes: | ||
| shortcodes: | ||
| - prerelease-docs-url.lua |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| -- Version-aware shortcode for linking to prerelease docs. | ||
| -- | ||
| -- Usage: {{< prerelease-docs-url 1.9 >}} | ||
| -- | ||
| -- Returns "prerelease." when the referenced version's docs live on | ||
| -- prerelease.quarto.org, or "" when they're on quarto.org. | ||
|
|
||
| local function handler(args, kwargs, meta, raw_args, context) | ||
| local ref_version = quarto.shortcode.read_arg(args, 1) | ||
| if ref_version == nil then | ||
| return quarto.shortcode.error_output( | ||
| "prerelease-docs-url", | ||
| "requires a version argument, e.g. {{< prerelease-docs-url 1.9 >}}", | ||
| context | ||
| ) | ||
| end | ||
| -- Strip surrounding quotes that may be preserved in text contexts | ||
| ref_version = ref_version:gsub('^"(.*)"$', '%1'):gsub("^'(.*)'$", '%1') | ||
|
|
||
| -- On the prerelease site, always link to prerelease | ||
| if quarto.project.profile:includes("prerelease-docs") then | ||
| return pandoc.Str("prerelease.") | ||
| end | ||
|
|
||
| -- Guard against missing or invalid version metadata | ||
| local version_str = meta["version"] and pandoc.utils.stringify(meta["version"]) or nil | ||
| if not version_str or version_str == "" then | ||
| return quarto.shortcode.error_output( | ||
| "prerelease-docs-url", | ||
| "missing 'version' in document metadata", | ||
| context | ||
| ) | ||
| end | ||
|
|
||
| -- Compare referenced version to this branch's version using | ||
| -- pandoc.types.Version for correct element-wise comparison (1.12 > 1.9) | ||
| local ok_branch, branch_version = pcall(pandoc.types.Version, version_str) | ||
| local ok_ref, ref = pcall(pandoc.types.Version, ref_version) | ||
|
|
||
| if not ok_branch then | ||
| return quarto.shortcode.error_output( | ||
| "prerelease-docs-url", | ||
| "invalid metadata version '" .. version_str .. "'", | ||
| context | ||
| ) | ||
| end | ||
| if not ok_ref then | ||
| return quarto.shortcode.error_output( | ||
| "prerelease-docs-url", | ||
| "invalid version argument '" .. ref_version .. "'", | ||
| context | ||
| ) | ||
| end | ||
|
|
||
| if ref <= branch_version then | ||
| return pandoc.Str("") | ||
| else | ||
| return pandoc.Str("prerelease.") | ||
| end | ||
| end | ||
|
|
||
| return {["prerelease-docs-url"] = handler} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| prerelease-title: Release Candidate | ||
| prerelease-lower: release candidate | ||
| prerelease-mode: Release Candidate | ||
| prerelease-link-subdomain: prerelease. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new required addition. We would version inside _quarto.yml, with different value on main and on prerelease branches.
This way we can behave differently based on this info retrieved in Lua.
This would replace
version: '1.9'in _quarto-prerelease-docs.yml - or duplicate.I mean, if we do modify in prerelease branch
version: 1.9in_quarto.yml, it won't be possible to forgot updating when we merge prerelease in main.Keeping it in
_quarto-prerelease-docs.ymltoo just allows to be able to doeven from main branch to activate the prerelease profile feature, if they need to be verify.
But usually
--profile prerelease-docsis only ever used with prerelease branchHope this is clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand. Is it worth adding an item to our release checklist to verify/update this value?