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

Enable specifying arbitrary yaml files as alternatives of _output.yml #1634

Merged
merged 12 commits into from
Aug 31, 2019

Conversation

atusy
Copy link
Collaborator

@atusy atusy commented Aug 29, 2019

This PR enables render() and YAML front matter to specify arbitrary yaml files as alternatives of _output.yml or _output.yaml, and closes #1613 .

render() supports it by the output_yaml argument and YAML front matter supports it by the output_yaml top level parameter.
There, multiple yaml files can be specified and the first existing one is used.
If output_yaml is specified both for render and YAML front matter, then render has the priority.
If none are found, then _output.yml or _output.yaml will be used if they exists.

Example

Prepare bar.yaml

list(
  html_document = list(toc = TRUE)
) %>%
  yaml::as.yaml() %>%
  writeLines("bar.yml")

Prepare test-yaml.Rmd

---
output: html_document
output_yaml:
  - foo.yml
  - bar.yml
---

# A

Render Rmd

If simply rendered by

render("test-yaml.Rmd")

then, bar.yml is used because foo.yml is missing.

Even if output_yaml is commented out from the YAML frontmatter, bar.yml can still be used via render().

render(
  "test-yaml.Rmd",
  output_yaml = "bar.yml"
)

@atusy atusy changed the title Output yaml Enable specifying arbitrary yaml files as alternatives of _output.yml Aug 29, 2019
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.

Looks good! Just nitpicking: could you change yaml to YAML in text (including comments)? Thanks!

@yihui yihui added this to the v1.16 milestone Aug 30, 2019
atusy and others added 2 commits August 31, 2019 06:09
Co-Authored-By: Yihui Xie <xie@yihui.name>
@atusy
Copy link
Collaborator Author

atusy commented Aug 30, 2019

Thanks a lot. Commited your suggestions and also fixed a grammar mistake.

@atusy
Copy link
Collaborator Author

atusy commented Aug 30, 2019

Oh I need to update docs as well.

@atusy
Copy link
Collaborator Author

atusy commented Aug 30, 2019

About the comments, I see lower case "yaml" in those not only edited by me.
Do you want me to fix them as well?

# yaml front matter discovery is done within render)

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.

I don't want to bring too much trivial work to you. Let's leave other instances of yaml behind. If you do want to change them, please feel free to do so in another PR. I don't really care. As I said, I was only nitpicking.

Thank you!

@yihui yihui merged commit b3ef007 into rstudio:master Aug 31, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: pass the name of the _output.yml to render
2 participants