Skip to content

Greater flexibility in repo specification #1036

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 40 commits into from
Jun 24, 2021
Merged

Greater flexibility in repo specification #1036

merged 40 commits into from
Jun 24, 2021

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Dec 1, 2020

Fix #1012

@kulbhushanchand
Copy link

Patiently waiting for the merger of this pull-request.

@maelle
Copy link
Contributor Author

maelle commented May 24, 2021

Maybe I should add tests first. 🤔

@apreshill apreshill added this to the v0.23 milestone May 29, 2021
R/bs4_book.R Outdated
@@ -615,3 +664,43 @@ bs4_check_dots <- function(...) {
)
}
}

# test helpers -----------------------------------------------------------------
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's plural but there's only one for now :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

is this only for test ? Meaning test helpers are stored inside the source of package ?
We usually store theme inside the test folder directly.

Also this function duplicates with bookdown::book_skeleton(), or the internal bookdown_skeleton() used for template. Maybe we can adapt those for the need of bs4_book(). It should be just a matter of rendering with special format (render_book(output_format = bookdown::bs4_book()))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the function should actually

  • call bookdown::book_skeleton
  • modify files if needed (content, YAML configs)
  • call render_book?

Copy link
Collaborator

Choose a reason for hiding this comment

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

modify files if needed (content, YAML configs)

Do you need to have special content in the Rmd for your test ? You should be able to control most of the config behavior from render_book()

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

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

I just add a quick look but here are a few comments.

Thanks!

R/bs4_book.R Outdated
@@ -615,3 +664,43 @@ bs4_check_dots <- function(...) {
)
}
}

# test helpers -----------------------------------------------------------------
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this only for test ? Meaning test helpers are stored inside the source of package ?
We usually store theme inside the test folder directly.

Also this function duplicates with bookdown::book_skeleton(), or the internal bookdown_skeleton() used for template. Maybe we can adapt those for the need of bs4_book(). It should be just a matter of rendering with special format (render_book(output_format = bookdown::bs4_book()))

name = name,
title = title,
author = author,
index_metadata = metadata,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the end the current test doesn't use it but I feel it might be useful?

Copy link
Collaborator

Choose a reason for hiding this comment

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

😅 it may not use it but as you set it to NULL in the test, you did not see that you created an issue in the first place as it has no default. 😉

I think we should stick to what is useful now - if we need it, it will be easy to add. If we don't, we'll have it in the codebase for nothing. Not great IMO.
It is also easier to adapt / modify when we don't have code part we try to preserve whereas they are not really used.

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

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

That looks great. I made a few comments.

About tests for this special format that works only on suggested package, do you know if CRAN expect tests to work only with Imports package or Suggests is ok ?

If they don't I believe we may need to add checks in tests or skip on CRAN all the testthat part so that is complies.

About xml2 used in testing for HTML output, is this something you have done in pkgdown also ?

Also, do we need to add something into the bs4_book() doc about github-repo field in index.Rmd YAML ? Do we need to set this metadata value to the same value as in this repo field ?

name = name,
title = title,
author = author,
index_metadata = metadata,
Copy link
Collaborator

Choose a reason for hiding this comment

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

😅 it may not use it but as you set it to NULL in the test, you did not see that you created an issue in the first place as it has no default. 😉

I think we should stick to what is useful now - if we need it, it will be easy to add. If we don't, we'll have it in the codebase for nothing. Not great IMO.
It is also easier to adapt / modify when we don't have code part we try to preserve whereas they are not really used.

@maelle
Copy link
Contributor Author

maelle commented Jun 15, 2021

That looks great. I made a few comments.

Thanks a lot for the feedback!

About tests for this special format that works only on suggested package, do you know if CRAN expect tests to work only with Imports package or Suggests is ok ?
If they don't I believe we may need to add checks in tests or skip on CRAN all the testthat part so that is complies.

Good point, I have added a helper skipper. Cf also r-lib/testthat#1398

About xml2 used in testing for HTML output, is this something you have done in pkgdown also ?

Definitely. Example 1, example 2.

Also, do we need to add something into the bs4_book() doc about github-repo field in index.Rmd YAML ? Do we need to set this metadata value to the same value as in this repo field ?

But bs4_book() does not use github-repo at all at the moment? Even in #1034 I haven't added. I actually do not know what this meta property does, actually. Maybe it should be tackled in that other PR?

@maelle maelle requested a review from cderv June 15, 2021 12:48
@cderv cderv self-assigned this Jun 24, 2021
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

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

That is ok. I'll take it from here.

@cderv cderv merged commit dfa56b5 into rstudio:master Jun 24, 2021
@cderv cderv removed their assignment Jun 24, 2021
@cderv
Copy link
Collaborator

cderv commented Jun 24, 2021

@yihui just so you know:

As discussed this includes new testthat infrastructure for bs4_boo() testing. Everything is skipped when either deps are not installed or Pandoc is not available. So tests should be run on CRAN if both condition are TRUE. This is as we dicussed I believe but we can skip on CRAN if it causes trouble somehow.

For the rest, it concerns the bs4_book() output only, excep a small tweak in bookdown::book_skeleton() to support a different path than working dir.

@yihui
Copy link
Contributor

yihui commented Jun 24, 2021

Sounds good. Thanks for letting me know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Greater flexibility in repo specification
5 participants