Giter VIP home page Giter VIP logo

downlit's Introduction

downlit

R-CMD-check Codecov test coverage CRAN status

The goal of downlit is to provide syntax highlighting and automatic linking of R code in a way that is easily used from RMarkdown packages like pkgdown, bookdown, and hugodown.

Installation

Install downlit from CRAN with:

install.packages("downlit")

Features

downlit has two slightly different highlighting/linking engines:

  • highlight() works with multiline code blocks and does syntax highlighting, function linking, and comment styling.
  • autolink() works with inline code and only does linking.

Multiline code blocks have:

  • Code syntax highlighted using R's parser.
  • Function calls automatically linked to their corresponding documentation.
  • Comments styled by transforming ANSI escapes sequences to their HTML equivalents (thanks fansi package).

The following forms of inline code are recognized and automatically linked:

  • fun(), pkg::fun().
  • ?fun, pkg::fun, type?topic.
  • help("fun"), help("fun", package = "package"), help(package = "package").
  • vignette("name"), vignette("name", package = "package").
  • library(package), require(package), requireNamespace("package").
  • {package} gets linked (if possible) and formatted as plain text.

Cross-package links

If downlit can find a pkgdown site for the remote package, it will link to it; otherwise it will link to https://rdrr.io/ for documentation, and CRAN for vignettes. In order for a pkgdown site to be findable, it needs to be listed in two places:

  • In the URL field in the DESCRIPTION, as in dplyr:

    URL: https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr
    
  • In the url field in _pkgdown.yml, as in dplyr

    url: https://dplyr.tidyverse.org

    When this field is defined, pkgdown generates a public facing pkgdown.yml file that provides metadata about the site:

    pandoc: '2.2'
    pkgdown: 1.3.0
    pkgdown_sha: ~
    articles:
      compatibility: compatibility.html
      dplyr: dplyr.html
    urls:
      reference: https://dplyr.tidyverse.org/reference
      article: https://dplyr.tidyverse.org/articles

So when you build a pkgdown site that links to the dplyr documentation (e.g., dplyr::mutate()), pkgdown looks first in dplyr's DESCRIPTION to find its website, then it looks for pkgdown.yml, and uses the metadata to generate the correct links.

Usage

downlit is designed to be used by other packages, and I expect most uses of downlit will use it via another package (e.g. hugodown). If you want to use it in your own package, you'll typically want to apply it as part of some bigger transformation process. You can get some sense of how this might work by reading the source code of downlit_html() and downlit_md(), which transform HTML and markdown documents respectively.

downlit's People

Contributors

arawles avatar cderv avatar davidchall avatar davisvaughan avatar dmurdoch avatar gadenbuie avatar hadley avatar indrajeetpatil avatar krlmlr avatar maelle avatar mdneuzerling avatar salim-b avatar strazto avatar zeehio avatar zkamvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

downlit's Issues

Custom class for output comments

Currently, output starting with # ... (especially the tidyverse output style #> ...) is treated as a regular comment. Readability-wise it would great to - at least have the chance to - assign a different class to output. Maybe this is just my personal preference and in this case please feel free to close this issue immediately.

For my own personal use I have installed a forked version of {downlit} which uses a (overly) simple implementation (ref. here and here). It assigns all "COMMENT" tokens which start with #> and have parent == 0 the class Generic.Output (go).

It would take some thinking to generalize this so that users can specify their own output style. The implementation seems to be easy as long output starts with a leading pound #. Another option would be to only allow tidy style output #> to have its own class.

Release downlit 0.2.1

Prepare for release:

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Auto-link system.file(..., package = pkg) calls to source file

When visiting the codemetar::write_codemetar() page, I expected the following code:

system.file("templates", "codemeta-github-actions.yml", package = "codemetar")

to lead me to source file but instead, it links to the unhelpful documentation of system.file(). I would expect/hope a link to https://github.com/ropensci/codemetar/blob/master/inst/templates/codemeta-github-actions.yml or https://raw.githubusercontent.com/ropensci/codemetar/master/inst/templates/codemeta-github-actions.yml.

I understand it may be difficult to link to the source file for arbitrary system.file() calls but calls relating to files from the package to which the pkgdown page relates to would be a good start. In the example here, since this is on the website for codemetar, it would work at least for system.file(..., package = "codemetar").

Feel free to move this issue if you believe this should be pkgdown's job.

Figure out context

Where else is it used in pkgdown; can downlit be fully responsible for it? How will pkgdown call downlit? Do exported functions need more options than pkgdown::autolink_html()?

Error while generating NEWS

https://github.com/tidyverse/purrr/runs/922354204?check_suite_focus=true#step:9:211

pkgdown::build_news()
── Building news ────────────────────────────────────────────────────────────────────────
Error: `x` must be a package name or a function inheriting from a namespace.
Run `rlang::last_error()` to see where the error occurred.
Run `rlang::last_error()` to see where the error occurred.

rlang::last_trace()
#> Backtrace:
#>      █
#>   1. └─pkgdown::build_news()
#>   2.   └─pkgdown:::build_news_single(pkg)
#>   3.     └─pkgdown:::data_news(pkg)
#>   4.       └─pkgdown:::markdown(path(pkg$src_path, "NEWS.md"))
#>   5.         └─downlit::downlit_html_node(xml)
#>   6.           └─downlit:::tweak_children(x, xpath_inline, autolink, replace = "contents")
#>   7.             └─downlit:::map_chr(text, fun, ...)
#>   8.               └─base::vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
#>   9.                 └─downlit:::FUN(X[[i]], ...)
#>  10.                   └─downlit::autolink_url(text)
#>  11.                     └─downlit:::href_expr(expr[[1]])
#>  12.                       └─downlit::href_topic(fun_name, pkg)
#>  13.                         └─downlit:::href_topic_local(topic)
#>  14.                           └─downlit:::href_topic_reexported(topic, getOption("downlit.package"))
#>  15.                             └─downlit:::find_reexport_source(obj, ns, topic)
#>  16.                               └─rlang::ns_env_name(get_env(obj))
#>  17.                                 └─rlang::ns_env(x)
#>  18.                                   └─rlang::abort("`x` must be a package name or a function inheriting from a namespace.")
#>  19.                                     └─rlang:::signal_abort(cnd)

Digging down the rabbit hole, it appears it's because purrr reexports is_null() from rlang. This symbol is an alias for is.null() so obj contains a primitive function here:

find_reexport_source(is.null, ns_env("purrr"), "is_null")
#> Error: `x` must be a package name or a function inheriting from a namespace.

More tolerant URL parsing?

The magick package has this URL field (cc @jeroen)

URL: https://docs.ropensci.org/magick (website) https://github.com/ropensci/magick (devel)

It's not parsed correctly by package_urls(). Would it make sense to use code/functions from desc?

desc::desc("/home/maelle/R/x86_64-pc-linux-gnu-library/3.6/magick/DESCRIPTION")$get_urls()
#> [1] "https://docs.ropensci.org/magick"   "https://github.com/ropensci/magick"

Created on 2020-06-09 by the reprex package (v0.3.0)

I am not sure how often DESCRIPTION URLs don't use "," as a separator.

[downlit] weird rendering in the presence of tab

Worst issue title ever, but I think I have a reprex. 😬

The R Markdown below

---
title: "Untitled"
output: hugodown::hugo_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


```{r eval=FALSE}

use_webcam <- function(width = 200, height = 200, margin = "1em") {
	htmltools::tagList(
		html_dependency_webcam(width, height)
	)
}
```

gets rendered to

---
title: "Untitled"
output: hugodown::hugo_document
rmd_hash: 89c2b1c227cd04c6

---

<div class="highlight">

<pre class='chroma'><code class='language-r' data-lang='r'>
<span class='k'>use_webcam</span> <span class='o'>&lt;-</span> <span class='nf'>function</span>(<span class='k'>width</span> = <span class='m'>200</span>, <span class='k'>height</span> = <span class='m'>200</span>, <span class='k'>margin</span> = <span class='s'>"1em"</span>) {
    htmltoo<span class='k'>htmltools</span>st<span class='nf'><a href='https://rdrr.io/pkg/htmltools/man/tag.html'>tagList</a></span>
        html_dependenc<span class='nf'>html_dependency_webcam</span>)<span class='k'>width</span><span class='k'>height</span>
    )
}</code></pre>

</div>


where "htmltoo" and "html_dependenc" are truncated.

Add a markdown option to auto-link?

In a blog post I'd like to e.g. use downlit::autolink("magick::channel_types") in text and get a Markdown link. Could autolink gain an argument helping to do that or should I write my own helper?

Provide option for RStudio default 'textmate' theme compatible highlighting

Working towards creating an option for RStudio textmate theme compatible highlighting. Initially creating the theme in the distill package but hopefully we can move it in to downlit if it's considered more generally useful.

I started with the built in haddock theme (which is pretty similar to textmate) and made the following changes:

rstudio/distill@02b2410...13fb0f6#diff-f088084fe658ee281215b486b2f18dab

Note that I left in all of the tokens not produced by downlit in case the pandoc highlighter produces them for other languages. Note that haddock defined no special handling for Float so I added that (along with DecVal using the same color as float). Not sure if there are other tokens that should be treated the same way?

Here are the remaining differences between RStudio's token handling and downlit's:

  1. Parentheses are given their own token type. While pandoc doesn't have a parentheses token type, in the default RStudio theme we highlight parentheses as operators so having a mode in downlit where parens are treated as operators would allow us to emulate this.

  2. NULL is treated as a constant. Here are all of the tokens we currently highlight as constants:

var builtinConstants = lang.arrayToMap([
   "NULL", "NA", "TRUE", "FALSE", "T", "F", "Inf",
   "NaN", "NA_integer_", "NA_real_", "NA_character_",
   "NA_complex_"
]);
  1. We define a set of "special functions" which we treat as language keywords. You may object to this, but I think that the line between "language keyword" and "function" in R is pretty slippery, and many language extensions (e.g. various class definition syntaxes) are functions. Suffice to say that the line drawn by the R tokenizer isn't a clean conceptual one :-) Anyway, here's our list of both keywords and special functions:
var keywords = lang.arrayToMap([
   "function", "if", "else", "in", "break", "next", "repeat", "for", "while"
]);

var specialFunctions = lang.arrayToMap([
   "return", "switch", "try", "tryCatch", "stop",
   "warning", "require", "library", "attach", "detach",
   "source", "setMethod", "setGeneric", "setGroupGeneric",
   "setClass", "setRefClass", "R6Class", "UseMethod", "NextMethod"
]);

Some of these decisions you might find questionable (this was Joe and I ~ 8 yrs ago trying to sort this out w/o much context as users). That said, I'm not aware of anyone ever complaining about our highlighting not making sense to them.

If you don't want to adopt any of these conventions in downlit, perhaps there could be a parameter added to highlight() to do RStudio compatible tokenizing?

Release downlit 0.1.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • devtools::check(remote = TRUE, manual = TRUE)
  • rhub::check_for_cran()
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_news_md()
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README

--atx-header deprecated with Pandoc 2.11.2

Just a warning that new version of Pandoc has now atx headers by default, and that they deprecated the argument.
See rstudio/rmarkdown#1956

downlit sets it, but there is no harm for now. Just a deprecated warning

> rmarkdown::pandoc_version()
[1] ‘2.11.2’
> downlit::downlit_md_string(c("# Header"))
[WARNING] Deprecated: --atx-headers. Use --markdown-headings=atx instead.
[1] "# Header\n"

Bug with R6?

In the code below I wouldn't expect get() to be linked.

downlit::highlight("x$get('get')")
#> [1] "<span class='k'>x</span><span class='o'>$</span><span class='nf'><a href='https://rdrr.io/r/base/get.html'>get</a></span>(<span class='s'>'get'</span>)"

Created on 2020-09-17 by the reprex package (v0.3.0.9001)

highlight failure

Bumped into this while trying to build renv's pkgdown site via pkgdown::build_site().

x <-
  structure(
    list(src = "# get the path to the project library\npath <- renv::paths$library()\n"),
    class = "source"
  )

downlit::highlight(x)
#> Error in `$<-.data.frame`(`*tmp*`, "href", value = c(NA, NA, NA, NA, NA, : replacement has 16 rows, data has 15

Created on 2020-10-15 by the reprex package (v0.3.0)

build_site() fails when two .Rd mans have the same \aliases

I have a package, where one function has the same name as the package, which is a case quite often, in my view. The package-level .Rd was built with usethis::use_package_doc(). When I call pkgdown::build_site(new_process = FALSE), following error occurs:

Error in vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE) : 
  values must be length 1,
 but FUN(X[[2]]) result is length 2
In addition: Warning messages:
1: In if (rdname == "reexports") { :
  the condition has length > 1 and only the first element will be used
2: In if (rdname == cur_rdname) { :
  the condition has length > 1 and only the first element will be used

Traceback:

href_topic_local(topic)
href_topic(fun_name, pkg)
href_expr(expr[[1]])
autolink_url(text)
FUN(X[[i]], ...)
vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
map_chr(text, fun, ...)
tweak_children(x, xpath_inline, autolink, replace = "contents")
downlit::downlit_html_node(xml)
markdown(src_path)
build_home_index(pkg, quiet = quiet)
build_home(pkg, override = override, preview = FALSE)
build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_run,
pkgdown::build_site(new_process = FALSE)

In the innermost call, there are two elements in rdnames: "package" and "package-package" (from usethis::use_package_doc()). This is the issue. A clash of two aliases in .Rd.

Ability to pass something else than classes to highlight

I'm trying to use downlit for Wordpress and was wondering whether it'd make sense to use colors as an argument instead of classes.

At the moment I'm using the same classes as the syntax highlighter plugin that Wordpress docs mention. Limitations

  • that highlighter doesn't seem adapted to add your own blocks and use its CSS (I didn't succeed in doing that https://rmd-wordpress.eu/rest-api-1/)

  • that highlighter seems to have less granularity than downlit (e.g. ":" is "r plain").

Should output comment get aria tag

So that reading (e.g) this doesn't repeat "hash greater than" again and again and again.

    summary(cars)
    #>      speed           dist       
    #>  Min.   : 4.0   Min.   :  2.00  
    #>  1st Qu.:12.0   1st Qu.: 26.00  
    #>  Median :15.0   Median : 36.00  
    #>  Mean   :15.4   Mean   : 42.98  
    #>  3rd Qu.:19.0   3rd Qu.: 56.00  
    #>  Max.   :25.0   Max.   :120.00

Created on 2020-08-17 by the reprex package (v0.3.0)

Check higlighting

test_that("fbind() binds factor (or character)", {
  x <- c("a", "b")
  x_fact <- factor(x)
  y <- c("c", "d")
  z <- factor(c("a", "b", "c", "d"))

  expect_identical(fbind(x, y), z)
  expect_identical(fbind(x_fact, y), z)
})

All hyperlinks to test_that().

Test source indexes

Create package, and then load with pkgload? (Would need to add to suggests, and create a test fixture)

Problem with multi-line calls

cat(downlit::highlight("mean('\n\n')"))
#> <span class='nf'><a href='https://rdrr.io/r/base/mean.html'>mean</a></span>(<span class='s'>'
#> 
#> '</span>ean('
#> 
#> ')

Created on 2020-07-31 by the reprex package (v0.3.0)

autolink does not work from some vignettes

Reprex:

downlit::autolink("vignette('dplyr', package = 'dplyr')")
#> [1] NA

I would have expected this to work as in example

downlit::autolink("vignette('grid', package = 'grid')")
#> [1] "<a href='https://cran.rstudio.com/web/packages/grid/vignettes/grid.pdf'>vignette('grid', package = 'grid')</a>"

I think this comes from the remote metadata to be retrieved:

article_index_remote <- function(package) {
# Ideally will use published metadata because that includes all articles
# not just vignettes
metadata <- remote_metadata(package)
if (!is.null(metadata)) {
return(metadata$articles)
}
# Otherwise, fallback to vignette index
path <- system.file("Meta", "vignette.rds", package = package)
if (path == "") {
return(character())
}
meta <- readRDS(path)
name <- tools::file_path_sans_ext(meta$File)
set_names(meta$PDF, name)
}

Metadata are retrieved but there is no element metadata$articles. The fallback method is not used (even if it could have worked)

downlit:::remote_metadata("dplyr")
#> $pandoc
#> [1] "2.7.3"
#> 
#> $pkgdown
#> [1] "1.5.1.9000"
#> 
#> $pkgdown_sha
#> [1] "eae56f08694abebf93cdfc0dd8e9ede06d8c815f"
#> 
#> $last_built
#> [1] "2020-08-12T15:33Z"
#> 
#> $urls
#> $urls$reference
#> [1] "https://dplyr.tidyverse.org/reference"
#> 
#> $urls$article
#> [1] "https://dplyr.tidyverse.org/articles"
Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  French_France.1252          
#>  ctype    French_France.1252          
#>  tz       Europe/Paris                
#>  date     2020-11-04                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                           
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.2)                   
#>  backports     1.2.0      2020-11-02 [1] CRAN (R 4.0.2)                   
#>  cli           2.1.0      2020-10-12 [1] CRAN (R 4.0.3)                   
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 4.0.2)                   
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.3)                   
#>  downlit       0.2.0.9000 2020-10-29 [1] github (r-lib/downlit@d0f5d32)   
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.2)                   
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.2)                   
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.0.2)                   
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)                   
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.0.2)                   
#>  htmltools     0.5.0      2020-06-16 [1] CRAN (R 4.0.2)                   
#>  knitr         1.30       2020-09-22 [1] CRAN (R 4.0.2)                   
#>  lifecycle     0.2.0      2020-03-06 [1] CRAN (R 4.0.2)                   
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 4.0.2)                   
#>  pillar        1.4.6      2020-07-10 [1] CRAN (R 4.0.2)                   
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.2)                   
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.2)                   
#>  reprex        0.3.0.9001 2020-10-21 [1] Github (tidyverse/reprex@d3fc4b8)
#>  rlang         0.4.8      2020-10-08 [1] CRAN (R 4.0.3)                   
#>  rmarkdown     2.5.2      2020-11-04 [1] local                            
#>  rstudioapi    0.11       2020-02-07 [1] CRAN (R 4.0.2)                   
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.2)                   
#>  stringi       1.5.3      2020-09-09 [1] CRAN (R 4.0.2)                   
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.2)                   
#>  styler        1.3.2      2020-02-23 [1] CRAN (R 4.0.2)                   
#>  tibble        3.0.4      2020-10-12 [1] CRAN (R 4.0.3)                   
#>  vctrs         0.3.4      2020-08-29 [1] RSPM (R 4.0.2)                   
#>  withr         2.3.0      2020-09-22 [1] CRAN (R 4.0.2)                   
#>  xfun          0.19       2020-10-30 [1] RSPM (R 4.0.3)                   
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                   
#> 
#> [1] C:/Users/chris/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library

should argument-less library(), vignette(), etc. be linked?

Should library() become [library()](https://rdrr.io/r/base/library.html) instead of not being linked? Or was it a design decision?

I've just noticed this in a post where I mention library() and require() and was a bit surprised they weren't linked.

Implement autolink_md()

Use pandoc to convert to json AST, parse to find code chunks, replace with raw HTML, then convert back to md.

Same chroma class:`NULL` and `if` as well as `library()` and other function names.

I am using {hugodown} and the academic theme to create a website. I try to recreate my favorite RStudio highlighting theme "cobalt". This is were I encountered the following issues:

(1) It seems like {downlit} assigns the same class kr(KeywordReserved) to NULL and if:
Bildschirmfoto 2020-07-22 um 22 41 24

highlight.js's R pattern uses here two different classes (similar to RStudio) called hljis-keyword and hljs-literal :
Bildschirmfoto 2020-07-22 um 22 40 45

Although I am still fiddling around (a lot), I think this has nothing to do with my setup, but is rather an issue of how the chroma classes are defined in downlit::highlight() here and here.

My question is: Is there a reason NULL and if are assigned to the same class, and could this be fixed?

Add on:
(2) A related issue is that library() calls are assigned the same class as regular functions (e.g. print()), both are of class nf (NameFunction). It would be great to have a separate class for library() calls, since RStudio highlights them differently. Here again highlight.js is making a distinction.

Manually style ANSI colours

Instead of relying on fansi — that way we could generate classes that are controlled by the theme. (Only need to support named colours + italic/bold/underline, so can probably just do with regexps)

could packages store preferred links?

Very niche issue :-)

distill has no pkgdown website which makes sense. Therefore downlit links functions to rdrr.io. It seems suboptimal compared to landing on distill distill website.

It made me think that it might be nice if packages could have some sort of YAML with function name & URL. It might be generated by roxygen2 using some tag, and would be in inst/ therefore installed.

This way

  • packages could use something else than a pkgdown website;

  • if I prefer folks to read a vignette rather than the man page, I can use that URL.

Look for metadata in package-local pkgdown.yml

Migrated from r-lib/pkgdown#1366

Previously named: Private (Enterprise Hosted) packages not autolinking due to requirement to sign-in

Hi there.

My organization hosts an instance of GH enterprise.

The Process

The current trajectory for autolinking is as follows (correct me if I'm wrong)

Read URL from package DESCRIPTION, for example:

URL: https://pages.github.sydney.edu.au/speed-extract/mandrake/

Resolve {url}/pkgdown.yml , use the links given here to help configure autolinking.

For example, DESCRIPTION$URL gives:

https://pages.github.sydney.edu.au/speed-extract/mandrake/pkgdown.yml

pandoc: '2.10'
pkgdown: 1.5.1.9000
pkgdown_sha: ~
articles: []
last_built: 2020-07-22T05:05Z
urls:
  reference: https://pages.github.sydney.edu.au/speed-extract/mandrake//reference
  article: https://pages.github.sydney.edu.au/speed-extract/mandrake//articles

pkgdown figures out the rest.

The problem with this process and enterprise hosted repos

This would be great, however, you will find that if you click on https://pages.github.sydney.edu.au/speed-extract/mandrake/pkgdown.yml

you will be given a challenge-response asking you to sign in.

curl says:

curl -I "https://pages.github.sydney.edu.au/speed-extract/mandrake/pkgdown.yml"
HTTP/1.1 302 Moved Temporarily
Server: GitHub.com
Date: Wed, 22 Jul 2020 06:27:49 GMT
Content-Type: text/html
Content-Length: 138
Location: https://github.sydney.edu.au/sessions/_auth_request_bounce?return_to=https%3A%2F%2Fpages.github.sydney.edu.au%2Fspeed-extract%2Fmandrake%2Fpkgdown.ym

So, pkgdown is never going to resolve those links.

Potential Fixes / Accomodations

I wonder, then, whether there are other ways pkgdown could accomodate linking enterprise hosted packages.
A few jump out:

  • 1 Allowing pkgdown.yml (The one deployed wherever our pkgdown site is deployed, eg https://pages.github.sydney.edu.au/speed-extract/mandrake/pkgdown.yml ) to be built into the package (Removing it from .Rbuildignore ) s.t if it is found, its url links are resolved automatically.
  • 2 If pkgdown attempts to resolve DESCRIPTION$URL/pkgdown.yml , and fails, pkgdown can make its best-effort based off of DESCRIPTION$URL to set up some "standard" links, such as:
    # base_url <- DESCRIPTION$URL
    urls$reference <- file.path(base_url, "reference")
    urls$article <- file.path(base_url, "articles")
    

These fall-backs might allow a best-effort linking for package's whose description$url field cannot be resolved publicly. I personally don't see too much harm in building a pkgdown.yml into installed R packages, so I think this could accomodate those of us who can't host all of our work publically.

Cheers!

store Rd elements as data-attributes for later use in tooltips (progressive enhancement)?

I.e. from usethis::use_git() produce

[`usethis::use_git()`](https://usethis.r-lib.org/reference/use_git.html "Initialise a git repository")

(Hugo recognizes it :-) ) or the equivalent html <a href='https://usethis.r-lib.org/reference/use_git.html' title='Initialise a git repository'>use_git</a>, depending on context.

The title would be the Rd title, or Package Title, or vignette title, depending on the linked thing.

Release downlit 0.2.0

Prepare for release:

  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS
  • Review pkgdown reference index for, e.g., missing topics

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.