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

Add bbt_update_bib #27

Merged
merged 8 commits into from Aug 2, 2021
Merged

Add bbt_update_bib #27

merged 8 commits into from Aug 2, 2021

Conversation

Robinlovelace
Copy link
Contributor

@Robinlovelace
Copy link
Contributor Author

This is a starter for 10. Any advice on how best to add tests appreciated. Thanks!

@paleolimbot
Copy link
Owner

Awesome! The only things I see are

  • You can probably pass on more arguments of bbt_write_bib(). You could use #' @inheritParams bbt_write_bib to document them so they stay current.
  • If you could add a test that would be great! One way would be to make a tiny mock file like this:
bib_file <- tempfile(fileext = ".bib")
mock_content <- sprintf('

---
bibliography: %s
---


This file contains a reference to @dunnington_etal18.

', bib_file)

rmd_file <- tempfile(fileext = ".Rmd")
readr::write_file(mock_content, rmd_file)

# run bbt_update_bib()

# expect_match(readr::read_file(bib_file), "dunnington_etal18")

unlink(c(rmd_file, bib_file))

Thank you!

@Robinlovelace
Copy link
Contributor Author

Good news, I got the tests to pass after adding your reference to Zotero and making it run, great way of testing this. There may well be other tweaks needed but happy with this from my perspective.

@Robinlovelace
Copy link
Contributor Author

Just getting this message on devtools::test() now and not sure why:

> devtools::test()
ℹ Loading rbbt
ℹ Testing rbbt
✔ |  OK F W S | Context
✔ |   6       | bbt-libraries [0.1 s]                                                                                                             
✔ |  15   2   | bbt [1.7 s]                                                                                                                       
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning (test-bbt.R:33:5): actions work
System clipboard contained no readable text. Returning NULL.
Backtrace:
 1. clipr::read_clip() test-bbt.R:33:4

Warning (test-bbt.R:36:5): actions work
Coercing content to character
Backtrace:
 1. clipr::write_clip(prev_clip) test-bbt.R:36:4
 2. clipr:::chosen_write_clip(...)
 3. clipr:::write_nix(...)
 4. clipr:::render_object(content, object_type, breaks, .dots)
 5. clipr:::flat_str(content, breaks)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ |   3       | detect-citations                                                                                                                  
✔ |   1       | update [0.2 s]                                                                                                                    
✔ |   8       | write-bib [0.5 s]                                                                                                                 

══ Results ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 2.5 s

[ FAIL 0 | WARN 2 | SKIP 0 | PASS 33 ]

@Robinlovelace
Copy link
Contributor Author

But when testing with Ctl+Shift+E I get this 🎉

Duration: 12.5s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

R CMD check succeeded

@paleolimbot paleolimbot merged commit 1e091f4 into paleolimbot:master Aug 2, 2021
@paleolimbot
Copy link
Owner

Thanks for this! I tweaked some details and added an RStudio addin...it's so good that I changed the recommended approach for RMarkdown integration!

Copy link
Contributor Author

@Robinlovelace Robinlovelace left a comment

Choose a reason for hiding this comment

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

Thanks for updating a merging this PR.


#' @rdname bbt_update_bib
#' @export
bbt_guess_bib_file <- function(path_rmd, encoding = "UTF-8") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great to see tests ensuring sane error messages. Impressive!

@Robinlovelace Robinlovelace deleted the update branch August 2, 2021 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants