Skip to content

Commit

Permalink
Merge pull request #3 from ThinkR-open/cran-0.1.0
Browse files Browse the repository at this point in the history
Release on CRAN 0.1.0
  • Loading branch information
statnmap authored May 6, 2024
2 parents 936cc01 + ec42011 commit 7e723bf
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
^pkgdown$
^doc$
^Meta$
^CONTRIBUTING\.md$
^cran-comments\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ README.html
docs
/doc/
/Meta/
cran-comments.md
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to 'lightparser'

This outlines how to propose a change to 'lightparser'.

## Use of 'fusen' to build the code base and documentation

Package 'fusen' is used to build the code base and documentation of 'lightparser'.
'fusen' is a package that provides a framework for building R packages from a Rmarkdown file (or Quarto file).
See documentation of 'fusen' for more details: https://thinkr-open.github.io/fusen

## Some tips to contribute with 'fusen'

- Most of modifications can be realized by modifying a 'flat' file in the "dev/" directory.
Then, run `fusen::inflate_all()` to generate the corresponding R, test or vignette files.

- You can see the list of all `active` flat files and the corresponding generated files by opening the "dev/config_fusen.yaml" file. There is one section for each flat file.

- You will see text like `"# WARNING - Generated by 'fusen' from dev/flat_***.Rmd: do not edit by hand"` on the top of all generated R, test or vignette files, when they are actually generated by 'fusen'.
All other file, not generated by 'fusen', should be listed under the `"keep"` section in the "dev/config_fusen.yaml" file. You can run `fusen::check_not_registered_files()` to check if that's the case.

### Modify documentation

- You will find the roxygen skeleton in the corresponding `function` chunk
- Text of the vignette is generally the text between chunk of the flat file

### Modify of a function

We recommend a test driven development approach:

- Write or modify a unit test in the corresponding `test` chunk of the function
- Modify the code of the function in the corresponding `function` chunk
- Run the 'inflate' command at the bottom of the flat file
- Run `devtools::test()` to check if the test is passing

To avoid multiple inflates, you can run the code locally

- Instead of inflating, run `fusen::load_flat_functions()` to load the function of the current flat file in your global environment
- Run your tests line by line from the `test` chunk
- You can also use your favorite debuging tools


## What if I do not understand 'fusen' ?

We are here to help.
If you know how to modify a package without 'fusen', contribute as you would do normally.
Forget the flat files for a moment. A 'fusen' package is still a classical package if you remove the "dev/" directory. There is no difference.

Open a Pull Request and we will help you to integrate your contribution in the 'fusen' framework.


## Code of Conduct

Please note that the 'lightparser' project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this
project you agree to abide by its terms.
15 changes: 8 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Package: lightparser
Title: From Rmd And Qmd To Tibble And Back
Version: 0.0.1
Title: From 'Rmarkdown' and 'Quarto' Files to Tibble and Back
Version: 0.1.0
Authors@R: c(
person("Sebastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1565-9313")),
person("ThinkR", role = "cph")
)
Description: Split your Rmd or Qmd file by sections into a tibble: titles,
text, chunks. Rebuild it from the tibble.
Description: Split your 'rmarkdown' or 'quarto' files by sections into a
tibble: titles, text, chunks. Rebuild the file from the tibble.
License: MIT + file LICENSE
URL: https://github.com/ThinkR-open/lightparser, https://thinkr-open.github.io/lightparser/
URL: https://github.com/ThinkR-open/lightparser,
https://thinkr-open.github.io/lightparser/
BugReports: https://github.com/ThinkR-open/lightparser/issues
Imports:
knitr,
knitr (>= 1.35),
rlang,
tibble,
utils,
Expand All @@ -27,4 +28,4 @@ Config/fusen/version: 0.6.0
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# lightparser 0.1.0

* Initial CRAN submission.

# lightparser 0.0.1

* `split_to_tbl()` to split a Rmd / Qmd into a tibble.
* `combine_tbl_to_file()` to combine a tibble into a Rmd / Qmd.
* Initial CRAN submission.

6 changes: 6 additions & 0 deletions R/lightparser-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
124 changes: 91 additions & 33 deletions dev/0-dev_history.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ usethis::git_default_branch_rename()
remotes::install_local()
# Code of Conduct
usethis::use_code_of_conduct("[email protected]")
# contributing
usethis::use_tidy_contributing()
```

**From now, you will need to "inflate" your package at least once to be able to use the following commands. Let's go to your flat template, and come back here later if/when needed.**
Expand Down Expand Up @@ -107,60 +109,119 @@ fusen::add_flat_template("add")
devtools::build_readme()
```

## Prepare for CRAN
# Prepare for CRAN

Copied from https://github.com/ThinkR-open/prepare-for-cran

```{r, eval=FALSE}
# Run examples in interactive mode too
# Prepare for CRAN ----
# Update dependencies in DESCRIPTION
# install.packages('attachment', repos = 'https://thinkr-open.r-universe.dev')
attachment::att_amend_desc()
# Check package coverage
covr::package_coverage()
covr::report()
# Run tests
devtools::test()
testthat::test_dir("tests/testthat/")
# Run examples
devtools::run_examples()
# Check package as CRAN
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
devtools::check(args = c("--no-manual", "--as-cran"))
# autotest::autotest_package(test = TRUE)
# Check package as CRAN using the correct CRAN repo
withr::with_options(list(repos = c(CRAN = "https://cloud.r-project.org/")), {
callr::default_repos()
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
})
# devtools::check(args = c("--no-manual", "--as-cran"))
# Check content
# remotes::install_github("ThinkR-open/checkhelper")
tags <- checkhelper::find_missing_tags()
View(tags$functions)
# install.packages('checkhelper', repos = 'https://thinkr-open.r-universe.dev')
# All functions must have either `@noRd` or an `@export`.
checkhelper::find_missing_tags()
# Remettre: Config/testthat/parallel: false dans DESCRIPTION
out <- checkhelper::check_clean_userspace(pkg = ".")
out
checkhelper::check_as_cran()
# Remettre: Config/testthat/parallel: true dans DESCRIPTION
# Check that you let the house clean after the check, examples and tests
# If you used parallel testing, you may need to avoid it for the next check with `Config/testthat/parallel: false` in DESCRIPTION
all_files_remaining <- checkhelper::check_clean_userspace()
all_files_remaining
# If needed, set back parallel testing with `Config/testthat/parallel: true` in DESCRIPTION
# Check spelling
# Check spelling - No typo
# usethis::use_spell_check()
spelling::spell_check_package()
# Check URL are correct
# remotes::install_github("r-lib/urlchecker")
# install.packages('urlchecker', repos = 'https://r-lib.r-universe.dev')
urlchecker::url_check()
urlchecker::url_update()
# Upgrade version number
usethis::use_version(which = c("patch", "minor", "major", "dev")[2])
# check on other distributions
# _rhub
devtools::check_rhub()
# List all R-hub platforms:
rhub::platforms()
rhub::check_on_windows(check_args = "--force-multiarch", show_status = FALSE)
rhub::check_on_solaris(show_status = FALSE)
rhub::check(platform = "debian-clang-devel", show_status = FALSE)
rhub::check(platform = "debian-gcc-devel", show_status = FALSE)
rhub::check(platform = "fedora-clang-devel", show_status = FALSE)
rhub::check(platform = "macos-m1-bigsur-release", show_status = FALSE)
rhub::check_for_cran(show_status = FALSE)
rhub::check(platform = "windows-x86_64-devel", show_status = FALSE)
buildpath <- devtools::build()
rhub::check_on_windows(
check_args = "--force-multiarch",
show_status = FALSE,
path = buildpath
)
rhub::check_on_solaris(show_status = FALSE, path = buildpath)
rhub::check(
platform = "debian-clang-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "debian-gcc-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "fedora-clang-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "macos-highsierra-release-cran",
show_status = FALSE,
path = buildpath
)
rhub::check_for_cran(show_status = FALSE, path = buildpath)
# _win devel
# _win devel CRAN
devtools::check_win_devel()
# _win release CRAN
devtools::check_win_release()
# remotes::install_github("r-lib/devtools")
# _macos CRAN
# Need to follow the URL proposed to see the results
devtools::check_mac_release()
# Check reverse dependencies
# remotes::install_github("r-lib/revdepcheck")
usethis::use_git_ignore("revdep/")
usethis::use_build_ignore("revdep/")
devtools::revdep()
library(revdepcheck)
# In another session because Rstudio interactive change your config:
id <- rstudioapi::terminalExecute("Rscript -e 'revdepcheck::revdep_check(num_workers = 4)'")
rstudioapi::terminalKill(id)
# if [Exit Code] is not 0, there is a problem !
# to see the problem: execute the command in a new terminal manually.
# See outputs now available in revdep/
revdep_details(revdep = "pkg")
revdep_summary() # table of results by package
revdep_report()
# Clean up when on CRAN
revdep_reset()
# Update NEWS
# Bump version manually and add list of changes
Expand All @@ -172,8 +233,5 @@ usethis::use_version(which = c("patch", "minor", "major", "dev")[1])
# Verify you're ready for release, and release
devtools::release()
# Back to dev
usethis::use_version(which = c("patch", "minor", "major", "dev")[4])
```

6 changes: 6 additions & 0 deletions dev/config_fusen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ flat_split_combine.Rmd:
check: false
document: true
overwrite: 'yes'
keep:
path: keep
state: active
R: R/globals.R
tests: []
vignettes: []
41 changes: 41 additions & 0 deletions dev/flat_split_combine.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,47 @@ test_that(
)
}
)
test_that("split_to_tbl can be run from within a Rmd file", {
temprmd <- tempfile(fileext = ".Rmd")
tempoutput <- tempfile(fileext = ".html")
cat(
"---",
"title: split inside Rmd",
"output: html_document",
"---",
"",
"\x60``{r}",
"library(lightparser)",
"file <- system.file('dev-template-parsing.Rmd', package = 'lightparser')",
"tbl_rmd <- split_to_tbl(file)",
"\x60``",
sep = "\n",
file = temprmd
)
expect_error(
rmarkdown::render(temprmd, output_file = tempoutput, quiet = TRUE),
regexp = NA
)
output_lines <- readLines(tempoutput)
# there should be a message about knitting
expect_true(
any(grepl(
"It seems you are currently knitting a Rmd/Qmd file.",
output_lines
))
)
# this message should be after the call to split_to_tbl
expect_true(
grepl(
"It seems you are currently knitting a Rmd/Qmd file.",
output_lines[grep("split_to_tbl", output_lines) + 1]
)
)
})
```

<!--
Expand Down
29 changes: 29 additions & 0 deletions man/lightparser-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e723bf

Please sign in to comment.