Since more then two people make use of this project, let me explain how to extend this package.
This package creates markdown and in some cases RMarkdown chunks. These chunks are displayed in nicely formated html because code sharing websites such as Github, Gitlab and Bitbucket display markdown files in the browser. It is very useful.
There are three types of functions.
badge_*
.travis.yml
.I previously used clunky and ugly code to do the search and placement actions. But I try to seperate that all out into simple functions.
If you have a badge that you would like to add, fork the project and
modify R/badges.R
,
tests/testthat/test_badges.R
, and
changelog.md
. Then give me a pull-request to add it to the
project.
A badge needs:
[](clickable link) # for example:
[](https://www.gnu.org/licenses/gpl-3.0.en.html)`
There is an internal function
badgepaste(imagelink = ,referlink = ,name = )
that makes
this easy:
`badgepaste(imagelink = "https://img.shields.io/badge/license-GPL--3-blue.svg", referlink = "https://www.gnu.org/licenses/gpl-3.0.en.html", name = "license")
test_badges.R
Add and modify
the following code to test your function. Usually you only need to test
if the link to the image is what you expect, you can assume that
badgepaste
works.context("name of badge")
test_that("description of test", {
badge <- your_badge_function("badgecreatr") # if you do multiple tests, this might help.
expect_match(badge, "\\[\\!\\[rpackages.io rank\\]") # here I test all the parts
expect_match(badge, "badge/badgecreatr.svg")
expect_match(badge, "www.rpackages.io/package/badgecreatr")
})
@param, @family badges, @return (markdown or Rmarkdown), @export (otherwise you can't use it
Like:
#' A title
#'
#' A description of what this is.
#' @param argument describe what this argument does, and defaults to
#' @family badges
#' @return markdown / Rmarkdown
#' @export
badge_yourfunction <- function(argument){
your function details
}
- badge for ... badge_name, by @githubname and full name if you like.
I don’t have any requirements, except a test that shows when it breaks.
Add a test that shows when this function breaks.