Skip to content
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

Pass parsed metadata into pre_knit #2485

Merged
merged 7 commits into from Sep 15, 2023
Merged

Pass parsed metadata into pre_knit #2485

merged 7 commits into from Sep 15, 2023

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented May 9, 2023

They will be read before pre_knit and access can be useful to do some side effect based on metadata in file. (use case in rticles)

Current workaround is to re-parse the YAML from the input file using rmarkdown::yaml_front_matter()

This is easy enough though, so maybe it is ok to keep it that way.

I opened the PR to share the idea as we always told in our doc that pre_knit should support ... for future expansion, and it seems ok to add

What do you think ? Did I miss something that would prevent us doing this ?

cderv added 2 commits May 9, 2023 11:42
They will be read before pre_knit and access can be useful to do some side effect based on metadata in file. (use case in rticles)

Current workaround is to re-parse the YAML from the input file.
@cderv cderv requested a review from yihui May 9, 2023 09:46
Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Sounds good! My only concern is whether all people have really followed the advice in the documentation to add the ... argument to their pre_knit function. We'll know when we do the revdeps check.

@cderv
Copy link
Collaborator Author

cderv commented May 9, 2023

My only concern is whether all people have really followed the advice in the documentation to add the ... argument to their pre_knit function. We'll know when we do the revdeps check.

yes I have the same concern. We'll see.

@atusy
Copy link
Contributor

atusy commented May 24, 2023

Maybe we can test if ... is available.

If not, we can fallback to the previous behavior with warning.

names(formals(function(x, ...) x))
#> [1] "x"   "..."

@atusy
Copy link
Contributor

atusy commented May 24, 2023

This warning will also be helpful when we add more arguments in the future.

@cderv
Copy link
Collaborator Author

cderv commented May 31, 2023

@yihui did you ran a reverse dependency check on that yet ?

I thought we would try merge it before next release and see if all passes but I think you have done the release already.

I'll run one on this for next release if you haven't done it.

@yihui
Copy link
Member

yihui commented May 31, 2023

Let's merge this after the next release (which is on its way). Thanks!

@yihui
Copy link
Member

yihui commented Sep 15, 2023

Sorry I forgot this PR. I just started the revdeps check: https://github.com/yihui/crandalf/actions/runs/6198690012/job/16829628626 I'm hoping to make a new release in the next few days if this PR works for revdeps.

@yihui
Copy link
Member

yihui commented Sep 15, 2023

Revdep checks are finished. Only one package would be broken: https://github.com/line/conflr/blob/74c3c36f0a786138d4d90f49df45ab165901761c/R/document.R#L133 Good news is that this package has been retired. Anyway, I'll use @atusy's idea above to test for the existence of ... in case we'd break any other packages not covered by our revdep checks.

@yihui yihui merged commit 4405efb into main Sep 15, 2023
18 checks passed
@yihui yihui deleted the pre-knit-metadata branch September 15, 2023 16:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants