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

Badge handling #195

Closed
jennybc opened this issue Jan 7, 2018 · 23 comments
Closed

Badge handling #195

jennybc opened this issue Jan 7, 2018 · 23 comments
Labels
feature a feature request or enhancement readme 🏠 Readme, badges, ...

Comments

@jennybc
Copy link
Member

jennybc commented Jan 7, 2018

Is there anything that could be done here or in a badge package to make badge-handling in the README nicer? For example, a better failure mode when a badge is unavailable.

@jennybc
Copy link
Member Author

jennybc commented Jan 8, 2018

Intriguing syntax but it's not working for me when primary image is specified the way our svg badges are.

<object data="nope.png" style="width:42px;height:42px;border:0;">
  <img src="kitten.jpg" alt="Live badge unavailable." style="width:42px;height:42px;border:0;" >
</object>

nope.png is the primary target and it cannot be found. kitten.jpg is the local fall back.

from https://stackoverflow.com/questions/10772346/display-alternate-image

I can get it to work if the remote badge is png, so maybe there is hope?

@jennybc
Copy link
Member Author

jennybc commented Jan 8, 2018

A previous discussion of the bad interaction btw specific version of pandoc and shields.io, resolved for codecov specifically by not using shields.io: #36

@jennybc
Copy link
Member Author

jennybc commented Jan 8, 2018

More wide-ranging badge discussion here: ropensci/unconf17#58

@jennybc jennybc added the feature a feature request or enhancement label Jan 16, 2018
@jennybc
Copy link
Member Author

jennybc commented Jan 28, 2018

Interesting input from Pandoc maintainer here, a thread about relaxing the self-containedness of html previews of md documents:

rstudio/rmarkdown#1238 (comment)

From the pandoc manual:
Elements with the attribute data-external="1" will be left alone; the documents they link to will not be incorporated in the document.

Perhaps we could incorporate the badges this way?


I just tried with two different variations on the badge syntax (putting the data-external="1" attribute in the <a> tag and in the <img>:

<a href="https://travis-ci.org/r-lib/usethis">
<img src="https://travis-ci.org/r-lib/usethis.svg?branch=master" alt="Travis build status" data-external="1"></a>

<a href="https://codecov.io/github/r-lib/usethis?branch=master" data-external="1">
<img src="https://codecov.io/gh/r-lib/usethis/branch/master/graph/badge.svg" alt="Coverage status"></a>

Neither works 😞. I get this failure when offline:

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS README.md --to html --from markdown_github-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none 
pandoc: Could not fetch https://travis-ci.org/r-lib/usethis.svg?branch=master
FailedConnectionException2 "travis-ci.org" 443 True getAddrInfo: does not exist (nodename nor servname provided, or not known)
Error: pandoc document conversion failed with error 67
Execution halted

so more investigation needed.

@cschwem2er
Copy link

I experience the same issues.

@jennybc
Copy link
Member Author

jennybc commented Feb 16, 2018

@methodds If you can, you should upgrade Pandoc. That should clear up most badge issues.

I'm leaving this open, because it would be nice to have a strategy that allowed README.Rmd to be previewed w/o an internet connection.

@cschwem2er
Copy link

Thanks for the hint, but unfortunately I still have the problem even with the latest pandoc version (2.1.1) :(

/usr/bin/pandoc +RTS -K512m -RTS README.md --to html4 --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW 
Could not fetch http://www.r-pkg.org/badges/version/stminsights
HttpExceptionRequest Request {
  host                 = "www.r-pkg.org"
  port                 = 80
  secure               = False
  requestHeaders       = []
  path                 = "/badges/version/stminsights"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 ConnectionTimeout
Error: pandoc document conversion failed with error 61
Execution halted

@jennybc
Copy link
Member Author

jennybc commented Feb 19, 2018

When I render README, I get:

/usr/local/bin/pandoc +RTS -K512m -RTS README.md --to html --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Users/jenny/resources/R/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW 

Why do I have --to html and you have --to html4? Is it possible you need to upgrade rmarkdown and its dependencies?

For me:

packageVersion("rmarkdown")
#> [1] '1.8'

Is this project and README on GitHub somewhere I can see?

@cschwem2er
Copy link

Thank you for helping me out :) Yes, the project is on github:
https://github.com/methodds/stminsights
In the current version though, I commented out the badge lines in preparation for a CRAN submission:

#[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/stminsights)](https://cran.r-project.org/package=stminsights)
#[![Travis-CI Build Status](https://travis-ci.org/methodds/stminsights.svg?branch=master)](https://travis-ci.org/methodds/stminsights)
#[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/methodds/stminsights?branch=master&svg=true)](https://ci.appveyor.com/project/methodds/stminsights)

Updating rmarkdown and its dependencies changed --to html, but unfortunately still doesn't work:

/usr/bin/pandoc +RTS -K512m -RTS README.md --to html --from gfm-ascii_identifiers --output README.html --standalone --self-contained --highlight-style pygments --template /home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/home/cs/R/x86_64-pc-linux-gnu-library/3.4/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW 
Could not fetch http://www.r-pkg.org/badges/version/stminsights
HttpExceptionRequest Request {
  host                 = "www.r-pkg.org"
  port                 = 80
  secure               = False
  requestHeaders       = []
  path                 = "/badges/version/stminsights"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 ConnectionTimeout
Error: pandoc document conversion failed with error 61
Execution halted

Here is my sessionInfo():

sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.3  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6 tools_3.4.3     yaml_2.1.16     Rcpp_0.12.15   
 [9] stringi_1.1.6   rmarkdown_1.8   knitr_1.19.2    stringr_1.2.0   digest_0.6.15   evaluate_0.10.1

@jennybc
Copy link
Member Author

jennybc commented Feb 19, 2018

Oooohh, this badge won't exist until your package gets on CRAN. So this is a known weird state that you just have to endure. Corrected: that is no longer true.

@hadley
Copy link
Member

hadley commented Feb 19, 2018

But the badge does exist: https://www.r-pkg.org/badges/version/stminsights.

@cschwem2er
Copy link

cschwem2er commented Feb 19, 2018

Wow... I removed the CRAN badge before, but this didn't work, probably because of the old pandoc version. Now it does, thank you! So basically there is no way to show a "not yet on CRAN" badge on github? This would surprise me because patchwork for instance does have the badge on github and it seems to be created with a .Rmdfile. @thomasp85 is using a slightly different syntax though:

[![CRAN_Release_Badge](http://www.r-pkg.org/badges/version-ago/patchwork)](https://CRAN.R-project.org/package=patchwork

@jennybc
Copy link
Member Author

jennybc commented Feb 19, 2018

So basically there is no way to show a "not yet on CRAN" badge on github

There is. You should always be able to render README.Rmd --> README.md. If the badge resolves, the image will appear on GitHub.

IME these Pandoc errors are only about creating the html preview for your local enjoyment. Caveat: that is not at all obvious -- it's easy to think that you have failed to knit to .md. It also leaves you in a frustrating situation of not being able to preview the .md locally.

@cschwem2er
Copy link

cschwem2er commented Feb 19, 2018

I see, thanks, but as least for me this still does not solve issues related to preparations for a CRAN submission. If I use devtools::release() after rendering with the CRAN badge, the following warning is raised:

Conversion of ‘README.md’ failed:
[WARNING] This document format requires a nonempty <title> element.
  Please specify either ‘title’ or ‘pagetitle’ in the metadata.
  Falling back to ‘README’
Could not fetch https://travis-ci.org/methodds/stminsights.svg?branch=master
HttpExceptionRequest Request {
  host                 = "travis-ci.org"
  port                 = 443
  secure               = True
  requestHeaders       = []
  path                 = "/methodds/stminsights.svg"
  queryString          = "?branch=master"
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}

This does not happen if I remove the CRAN badge (and then of course the HTML preview also works).

@jennybc
Copy link
Member Author

jennybc commented Feb 19, 2018

WARNING] This document format requires a nonempty <title> element.
  Please specify either ‘title’ or ‘pagetitle’ in the metadata.
  Falling back to ‘README’

This is highly suggestive that you don't have the most recent version of rmarkdown.

rstudio/rmarkdown#1200

I also have a suspicion that rmarkdown may be finding an older version of Pandoc. You might want to place rmarkdown::pandoc_version() in README.Rmd as an experiment.

@cschwem2er
Copy link

cschwem2er commented Feb 19, 2018

This is output generated by rendering my README.Rmd and adding syntax as you suggested:

library(rmarkdown)
sessionInfo()

#> R version 3.4.3 (2017-11-30)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Linux Mint 18.3
#> 
#> Matrix products: default
#> BLAS: /usr/lib/libblas/libblas.so.3.6.0
#> LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rmarkdown_1.8
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.4.3  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2
#>  [5] tools_3.4.3     htmltools_0.3.6 yaml_2.1.16     Rcpp_0.12.15   
#>  [9] stringi_1.1.6   knitr_1.19.2    stringr_1.2.0   digest_0.6.15  
#> [13] evaluate_0.10.1

rmarkdown::pandoc_version()
#> [1] '2.1.1'

It seems like rmarkdown and pandoc versions are both up to date.

@jennybc
Copy link
Member Author

jennybc commented Feb 19, 2018

Then I'm afraid I do not know what's going on. I note that you originally had trouble with the CRAN badge, but the most recent error is about Travis, in case that helps your troubleshooting. Perhaps that was just intermittent bad luck.

@cschwem2er
Copy link

The most recent error is always about the CRAN badge or the badge that comes after the CRAN badge. This is another run:

[WARNING] This document format requires a nonempty <title> element.
  Please specify either ‘title’ or ‘pagetitle’ in the metadata.
  Falling back to ‘README’
Could not fetch https://www.r-pkg.org/badges/version-ago/stminsights
HttpExceptionRequest Request {
  host                 = "www.r-pkg.org"
  port                 = 443
  secure               = True
  requestHeaders       = []
  path                 = "/badges/version-ago/stminsights"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}

Anyway, thank you for trying to help me multiple times! If I find a solution, I let you know.

@lorenzwalthert
Copy link
Contributor

@cschwem2er have you figured it out? I have the same R CMD CHECK warnings at the CRAN infrastructure for incoming checks you outlined and I don't know what to do. Neither travis, appveyor or r-hub give me these warnings. Did removing all badges help?

@cschwem2er
Copy link

Unfortunately I still do not have a solution other than removing the badges for the CRAN submission and readding them manually afterwards :/

@lorenzwalthert
Copy link
Contributor

lorenzwalthert commented Nov 20, 2018

Thanks. Ok, but it has worked for styler 1.1.0 🍾.

@hadley hadley added the readme 🏠 Readme, badges, ... label Nov 24, 2018
@hadley
Copy link
Member

hadley commented Nov 29, 2018

I think this is both largely resolved and outside the scope of usethis.

@ferroao
Copy link

ferroao commented Feb 26, 2020

@cschwem2er have you figured it out? I have the same R CMD CHECK warnings at the CRAN infrastructure for incoming checks you outlined and I don't know what to do. Neither travis, appveyor or r-hub give me these warnings. Did removing all badges help?

Check if any of your badges names (if files) gets matched by your patterns in .RbuildIgnore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement readme 🏠 Readme, badges, ...
Projects
None yet
Development

No branches or pull requests

5 participants