-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
Patiently waiting for the merger of this pull-request. |
Maybe I should add tests first. 🤔 |
R/bs4_book.R
Outdated
@@ -615,3 +664,43 @@ bs4_check_dots <- function(...) { | |||
) | |||
} | |||
} | |||
|
|||
# test helpers ----------------------------------------------------------------- |
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.
it's plural but there's only one for now :-)
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.
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())
)
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.
So the function should actually
- call
bookdown::book_skeleton
- modify files if needed (content, YAML configs)
- call
render_book
?
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.
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()
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 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 ----------------------------------------------------------------- |
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.
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())
)
tests/testthat/helper-bs4_book.R
Outdated
name = name, | ||
title = title, | ||
author = author, | ||
index_metadata = metadata, |
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.
in the end the current test doesn't use it but I feel it might be useful?
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.
😅 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.
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.
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 ?
tests/testthat/helper-bs4_book.R
Outdated
name = name, | ||
title = title, | ||
author = author, | ||
index_metadata = metadata, |
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.
😅 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.
Thanks a lot for the feedback!
Good point, I have added a helper skipper. Cf also r-lib/testthat#1398
Definitely. Example 1, example 2.
But |
to see the logic clearer imo.
I think it works here because library(bookdown) is called and the function is found. But sometimes it does not, so I prefer to use the book namespaced name
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.
That is ok. I'll take it from here.
@yihui just so you know: As discussed this includes new testthat infrastructure for For the rest, it concerns the |
Sounds good. Thanks for letting me know! |
Fix #1012